"text-align: center" is really only supposed to apply to text and it works in IE only because IE doesn't interpret it properly.

The CORRECT way to do it is:

body {
        text-align: center;
} /* for IE */
div#container {
        margin: 0 auto;
        text-align: left;
} /* for standards-compliant browsers */

<html>
<body>
<div id="container">

</div>
</body>
</html>

The "margin" setting means 0 for top and bottom, and auto margins for left and right, which throws the div into the center.

William Stewart wrote:
Hello everyone,

I am working on a site that has a fixed-width design aligned in the
middle (horizontally) of the screen.  I am doing this tableless and in
XHTML 1.0 Transitional - that's always a recipe for long nights trying
to get it to work.

Herein, lieth the problem.  To center the design in the middle of the
screen, I would normally do align="center" with the container div.  The
problem is, that perfectly wonderful property attribute is now
deprecated in XHTML 1.0 Transitional.  I came up with a solution that
works in IE, but is does not in the Mozilla/Netscape/Firefox family:

body {
        text-align: center;
}

div.main {
        text-align: left;
}

Of course, the text goes in the div and everything is beautiful in IE
although the other browsers align it left still.  I fixed it in M/N/F by
using <center> to envelop everything, but it will make all the text
centered if there is no style sheet loaded.

Is there another solution that I am not thinking about?

--
::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
Wise-cracking quote goes here.

____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub


________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.



Reply via email to