Once again i have a simple question i am sure.
I am trying to center a page using CSS and not having much luck in IE. The following code works with Netscape and Mozzila. Any suggestions would be greatly appreciated!!
<html>
<head>
<STYLE TYPE='text/css'>
body { width: 800px; margin: 0 auto; }
</STYLE>
</head>
<body>
This is a test of page centering
</body>
</html>First try using a full valid doctype to put IE into standards mode. If that doesn't work then you have to use text-align:center to get IE to center things; it doesn't understand margin:autriginally posted by ray326
it doesn't understand margin:auto. IE6 does, just not older versions of IE.opera dooesn't understand margin: 0 auto;<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>center contents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {text-align: center}
#alignment {text-align: left; margin: auto auto; width:60%;}
p {background:red;}
-->
</style>
</head>
<body>
<div id="alignment">
<p>contents</p>
</div>
</body>
</html>Thanks all, your help has been invaluable!!!
I am trying to center a page using CSS and not having much luck in IE. The following code works with Netscape and Mozzila. Any suggestions would be greatly appreciated!!
<html>
<head>
<STYLE TYPE='text/css'>
body { width: 800px; margin: 0 auto; }
</STYLE>
</head>
<body>
This is a test of page centering
</body>
</html>First try using a full valid doctype to put IE into standards mode. If that doesn't work then you have to use text-align:center to get IE to center things; it doesn't understand margin:autriginally posted by ray326
it doesn't understand margin:auto. IE6 does, just not older versions of IE.opera dooesn't understand margin: 0 auto;<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>center contents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {text-align: center}
#alignment {text-align: left; margin: auto auto; width:60%;}
p {background:red;}
-->
</style>
</head>
<body>
<div id="alignment">
<p>contents</p>
</div>
</body>
</html>Thanks all, your help has been invaluable!!!