Quick CSS question

DannyBoy

Diamond Member
Nov 27, 2002
8,820
2
81
www.danj.me
Is there any simple way to center a <div> tag in a CSS doc?

Obviously <div align="center"> would normally work but I can't seem to find anyway of doing it inside the stylesheet :|

Ta.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
you'll need to create an extra wrapper <div> just under body so that it goes this way:

<body>
<div id="wrapper">
...
</div>
</body>

In the stylesheet
body {
text-align: center; /* for IE */
}

div#wrapper {
margin: 0 auto; /* for other browsers */
text-align; left; /* reset text alignment to left */
}