Den her er valideret xHTML 1.0 Strict, og er testet i IE6:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Horisontal og Vertikal Centrering via CSS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {
margin:0px; padding:0px;
}
#center {
padding:20px;
border:1px solid #000000;
width:300px;
height:300px;
margin-left:-171px; /* -((Width / 2) - padding - border) */
margin-top:-171px; /* -((Height / 2) - padding - border) */
position:absolute;
left:50%;
top:50%;
}
</style>
</head>
<body>
<div id="center">
Horisontalt og vertikalt centreret!
</div>
</body>
</html>
MvH
Stefan Svensson
http://fusket.frac.dk