I am trying to understand a problem in my web development. I am developing in an XP environment with IE 8. To get to the route of the problem, I developed a very simple web page.
It basically consists of two elements. A body (with a red background) and a Div (with a green background). I set the height of the div to 100%. I would expect the div to fill the page since both height and width are 100%. But instead I get a thin div, maybe half a cm in height that stretches nearly to the left and right edges of the page. If I specify the height of the div as an absolute number of pixels (e.g. 512px) I can increase the height of the div. But this is not going to work for me since I need to accommodate users with different screen resolutions. There is something fundamental that I am not getting here. Can someone help me?
Here is the content of the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>TEST</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" media="all"/>
</head>
<body>
<div id="container">
</div>
</body>
</html>
And here is the style sheet associated with the page.
body
{
text-align:center;
background-color:red;
}
#container
{
width:100%;
height:100%;
background-color:green;
}