I have a div with the <h1> in a div, no margins. If I define any type of doctype, a space will be displayed above the div.
If I remove the <h1> tags or remove the doctype definition, there is no place (as it should be. Why?
HTML example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> body { margin:0 } #thediv { background-color:green } </style> </head> <body> <div id="thediv"> <h1>test</h1> </div> </body> </html>
The problem is the space above the green div, remove the DOCTYPE and the space will disappear, change the <h1> to <b> and the space will also disappear. This happens with any doctype (XHTML / HTML, strict / transitional / etc)
It happens in almost all browsers (using http://browsershots.org ). Curiously, the only browser that seems to display it correctly was Internet Explorer 6.0.
source share