Click to See Complete Forum and Search --> : Center a Div - Just not working


JPW
07-06-2008, 02:52 PM
I want to center one div on my web page.

It will stay center, but at the same time is always at the top of the browser window. I want it horizontally and vertically central.

I don't get what's wrong :/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">@charset "utf-8";
/* CSS Document */

body {
margin: 0;
padding: 0;
text-align: center;
background-color: #CC0000;
color:#FFFFFF;
}
#wrapper {

width: 400px;
margin: 0 auto;
background-color:#66FF66;}</style>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Index Page</title>
<link href="/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">Web Page Under Construction</div>
</html>
</body>
</html>

WebJoel
07-06-2008, 04:08 PM
Google "centering vertical and horizontal" or some such, and get many examples like this:

http://www.infinitywebdesign.com/research/cssverticalcentereddiv.htm

:)