Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- How to center images


isitreal - 5:37 pm on Feb 9, 2004 (gmt 0)


I keep reading margin:0 auto; as a solution but it doesn't work in IE. However, it does work if you create another div with propery text-align:center, just like with the image, which actually takes care of the problem in terms of getting rid of the <div align="center"> tag which is what was keeping me from having xhtml 1 strict doc types, so thanks for helping pinpoint the problem.

Can't you just enclose the page in a div and use the normal auto-margin technique?

<html>
<head>
<title></title>
<style type="text/css">
body, html {margin:0; padding:0;}
#maincontainer {text-align:center;}
#content {width:600px;height:300px;background-color:green;margin:0 auto;}
</style>
</head>
<body>
<div id="maincontainer">
<div id="content">words</div>
</div>
</body>
</html>


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