My html page is:
<html>
<head>
<title>Hello there</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="content">
Hello world
</div>
</body>
</html>
My css file is:
html, body{
width: 100%;
height: 100%;
}
div#content{
width: 80%;
display: block;
margin: 0 auto;
height: 90%;
border: 1px solid red;
}
But the content div is not centered properly.
I am using IE7 to view this page.
You should add a
<!doctype>to the beginning of your document, also remove thedisplay: block;from your div selector, a div is by default a block level element so this declaration has no meaning. (this won’t break the layout, it just makes no sense to tell an already block level element to be block again.)Other than that, your CSS is perfectly fine 🙂
HTML:
CSS:
http://jsfiddle.net/u5w8F/