I've noticed that CSS using relative positioning will be handled very differently if my web page contains the HTML5 doctype header <!DOCTYPE HTML>
. For example:
<html>
<body>
<img src="test.png" />
<span style="position: relative; top: -10;">TEST</span>
</body>
</html>
will render the word TEST aligned 10 pixels higher than its default position like so:
But if I add <!DOCTYPE HTML>
to the top of the document and make no other changes:
<!DOCTYPE HTML>
<html>
<body>
<img src="test.png" />
<span style="position: relative; top: -10;">TEST</span>
</body>
</html>
then the relative positioning appears to have no affect on the word TEST:
This behavior is consistent in the latest versions of IE, Chrome, and Firefox on Windows. I've noticed other quirky behavior when using absolute positioning with and without the HTML5 doctype header.
Is there a fundamental change on how relative and absolute positioning is applied in HTML5?