Solved

div tag not centering in firefox

Posted on 2007-11-22
4
741 Views
Last Modified: 2008-02-01
I have a div tag that is set to center my log in control and it works in IE, but left aligns in firefox:

    <div style="text-align: center">

How do I get that panel to center in firefox too?

thanks!
0
Comment
Question by:Starr Duskk
4 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 20337473
Use ...

    <div align="center">

This will center in all browsers.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20337484
sure enough. thanks!
0
 
LVL 1

Expert Comment

by:edenmachine
ID: 20337501
Alternatively you can just make the div 100% in width so that the text can center inside of it:

<div style="text-align: center; width:100%;">
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20337608
You should use style.  The align attribute is deprecated.  However depending on what your "log in control" is the text-align: center style may not work; it is just for text.  An alternative is to make the div the size of the control and then use margin.  This will actually center the div itself in the page, not just the contents.  For example ...

<div style="width: 150px; margin: 0 auto;">

The key to the centering is the limited size (i.e. not 100% and the auto for the left and right side of the margin.

bol
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question