Reputation: 164
Why would this code leave a white strip at the top of the page in google chrome ?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>title goes here</title>
</head>
<body style="margin:0px 0px 0px 0px;padding:0px 0px 0px 0px">
<form id="form1" runat="server" style="padding:0px 0px 0px 0px;margin:0px 0px 0px 0px">
<div style="background-color: blue;">
<p> </p>
</div>
</form>
<p> </p>
</body>
</html>
Upvotes: 6
Views: 1929
Reputation: 174
The white line is coming from the white space left behind by the line break created by the p tag. Just remove the p tag and it will be gone.
<div style="background-color: blue;">
 
</div>
Upvotes: 0
Reputation:
The p-tag has a margin that affects its parents.
Add overflow: auto;
to the div with the background. That prevents margins from collapsing
Upvotes: 10
Reputation: 262
Try adding margin:0;
and padding=0;
to the html
element as well.
Also, this is a bit far-fetched, but I experienced a similar problem with php files where a utf-8 encoded one with BOM would create an empty line before everything else.
Upvotes: 0