tags:

views:

58

answers:

3

html:

<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="qa.css" />
</head>
<body>
<div id="wrap"></div>
</body>
</html>

css:

body {
margin:0;
padding:0;
}

#wrap {
width:750px;
margin-right:auto;
margin-left:auto;
background:#008B00;
}

The html file is called qa.html, and the css file is called qa.css The two files are in the same directory.

+4  A: 

Um... How's the HTML supposed to show anything if there's no content?

[EDIT] To make it more specific and not sound like I'm complaining: put some content in the wrapper div, otherwise it's empty and thus with 0 height.

[EDIT 2]: According to the expected output you describe in the comment, you want the div to take up 100% height of the document. You need to specify this explicitly, ie body and #wrap need to have height:100%. Or even better, min-height.

mingos
<html><head><title>Home</title><link rel="stylesheet" type="text/css" href="qa.css" /></head><body><div id="wrap"><p>Hello</p></div></body></html>
Justin Meltzer
This still doesnt work...
Justin Meltzer
body { margin: 0; padding: 0; height: 100%;}#wrap { width: 750px; margin-right: auto; margin-left: auto; background: #008B00; min-height: 100%;}
mingos
The height values are the key here.
mingos
+2  A: 

The div will collapse upon itself if there is no content and no height set. Either put some text or content into the div, or set a min-height or height explicitly.

Edit: please put a doctype in your pages; it helps a lot with expected renderings.

Delan Azabani
i put content in the div, and the page doesn't show anything. Any other possibilities as to what I could be doing wrong?
Justin Meltzer
+1 for doctype.
rossisdead
+1  A: 

a green div block that fills the middle 750 pixels of the page.

So,

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

#wrap {
    width: 750px;
    height: 100%;
    margin: 0 auto;
    background: #008B00;
}

?

BalusC
Yeah, that's what I'm suggesting as well. Confirmed working, at least in Chrome ;)
mingos
The key is giving `height: 100%` to `html` as well.
BalusC
I've heard others claim this, but no, body is actually enough.
mingos