The other way around to center an element is by using the centering technique for block elements (highlighted):
Code:
<style type="text/css">
#wrap{
width:500px;
margin:20px auto;
border:1px solid red;
text-align:center;
}
</style>
<div id="wrap">This is the content of wrap div</div>
...this should work well on FF, but IE, being on quirksmode, must have a DTD:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
...so the complete code which works cross-browser and will center your element on any resolution is:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
#wrap{width:500px;margin:20px auto;border:1px solid red;text-align:center;}
</style>
</head>
<body>
<div id="wrap">This is the content of wrap div</div>
</body>
</html>
Also note the center is a deprecated tag, and should'nt be advocated.
Hope that makes sense.
Bookmarks