Reputation: 1512
Suppose we have a simple HTML page:
<html>
<body style="background-color: red; width: 100px; height: 100px; border: 1px solid black">
</body>
</html>
Browsers (except for IE) would render it like this:
The question is why does the area outside the body element (which itself is 100px wide and 100px high) have a red background?
Upvotes: 2
Views: 1474
Reputation: 433
This example can be made to work, but you will need to apply styles to both the HTML tag and the BODY tag, like so:
<html style="background-color:white;">
<head></head>
<body style="background-color: red; width: 100px; height: 100px; border: 1px solid black">
</body>
</html>
Upvotes: 0
Reputation: 45578
Because the bodys background is the one that the whole page gets assigned, too. What would you expect? A white background that you can't get rid of?
Upvotes: 0
Reputation: 441
'cause body is your entire document. you can't limit it to 100x100px.
you may use a div to create your box :
<html>
<body>
<div style="background-color: red; width: 100px; height: 100px; border: 1px solid black"></div>
</body>
</html>
Upvotes: 3
Reputation: 37504
I can only assume because you havent specified a background color for your 100x100px square? (only a guess without seeing more of your CSS code)
Upvotes: 0