W3C home > Mailing lists > Public > www-validator@w3.org > September 2002

RE: align="center"

From: bronco <bronco@cwo.com>
Date: Sat, 21 Sep 2002 00:10:33 -0400 (EDT)
Message-ID: <001201c26124$cd970a60$6401a8c0@wasaba>
To: <www-validator@w3.org>
Cc: "Gannon J. Dick" <gdick@verizon.net>

I think you have something there.  I looked up the text-align property and it turns out that it affects any block level element.  This turns out to be very cool because <body>, <div> and a bunch of other elements are block level elements.  So, I think you and Ian just gave me my answer.

My goal is to be able to get the same effect align has centering tables( <table align="center"> ), but with the <div>.  Since "align" is deprecated, it took a tiny trick using the text-align property, not on <div>, but on <body>.  If you use it directly on <div> you just get a bunch of centered stuff.  So, I moved it up to <body>. 

It *was* necessary to set the margins to auto, so, Ian, I took your recomendation, too.   A little here, a little there and you have a <div> that centers properly.  Hope I didn't break any rules.

<body style="text-align : center; color : white; background-color : #333344;font-family : Verdana, Tahoma, Helvetica, sans-serif; font-size:1.5em;color:#222222;">
 <div style=" width:400px;text-align:left; background-color:#ffffff;margin-right : auto; margin-left : auto;" >
<p>Lorem ipsum dolo sit amet, sit a, consectetuer adipiscing elit, sit a, diam nonummy nibh uismo sit a, cidunt ut laoreet dolore mag sit a, aliquam erat volutpat.</p>

I guess I should check my work by  validating this.

Steven B.
Received on Sunday, 22 September 2002 07:12:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:58:29 UTC