Hi there Ron,
there is one slight drawback to your centering method. 
When reducing the height of the page, there will come a point where the top of the #container div disappears. 
The following method avoids this problem...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<base href="http://nopeople.com/CSS%20tips/vertical%20center%20with%20CSS/">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>centered vertically and horizontally</title>
<style type="text/css">
html,body {
height:100%;
min-height:210px; /* same as the #container height */
margin:0;
background:#fc6;
font:normal 11px 'comic sans ms',sans-serif;
color:#333;
}
#vertical {
float:left;
width:100%;
height:50%;
margin-top:-105px; /* half the #container height */
}
#container {
clear:both;
width:300px;
height:210px;
margin:auto;
background:#ccc;
}
#container p {
margin:0;
text-align:center;
line-height:25px;
}
#container img {
width:195px;
height:175px;
}
</style>
</head>
<body>
<div id="vertical"></div>
<div id="container">
<p>This is vertically & horizontally centered.
<img src="boat.jpg" alt="fishing boat">
</p>
</div>
</body>
</html>
coothead
Bookmarks