Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- Simple CSS question


tedster - 7:09 am on Aug 18, 2001 (gmt 0)


This apparently simple thing has confounded me also, Jake. It sounds like your approach ought to work — use text-align:center to center a nested div, and then declare text-align:left for that nested div, in order to override the centering of elements that would be inherited from the outer div.

But it only works in Explorer, and not even Opera.


<HTML>
<HEAD>

<style>
#container {width:100%;text-align:center}
#pageitself {width:580px;text-align:left}
</style>

</HEAD>
<BODY>

<div id="container">
<div id="pageitself">This is the page we want to be centered.</div>
</div>

</BODY>
</HTML>

The old, deprecated <CENTER> tag was simple and elegant for this kind of functioning. In Opera and Netscape 6 th e <center> tag will still center a div on the page, even though it's now deprecated. But not in Netscape 4.x! No method I can find will center an entire div in Netscape 4.x.

My guess is that tables are still required to get this centering effect with the current browser situation. I'd sure love to hear differently.


Thread source:: http://www.webmasterworld.com/css/35.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com