Reputation: 21
I'm trying to make something 100% height and adding a doctype breaks that. That was explained on other questions. However, I found something weird -- if I close the doctype tag (which I know you're not supposed to do) then 100% height works again on both chrome and IE. What exactly is happening then? Does closing the doctype mean the doctype is being ignored?
<!doctype html/> <!--You're not supposed to close doctype but if you do, then
the 100% sizing works. Why?-->
<html>
<body>
<!--This 100% height won't work with a normal doctype but closing
the doctype makes it work?-->
<div style="border:5px solid black;height:100%">This should be 100%</div>
</body>
</html>
Upvotes: 0
Views: 38
Reputation: 288220
According to 8.1.1 The DOCTYPE,
A DOCTYPE must consist of the following components, in this order:
- A string that is an ASCII case-insensitive match for the string "
- One or more space characters.
- A string that is an ASCII case-insensitive match for the string "html".
- Optionally, a DOCTYPE legacy string or an obsolete permitted DOCTYPE string (defined below).
- Zero or more space characters.
- A ">" (U+003E) character.
Therefore, your "closed doctype" is an invalid doctype. And thus it's like you had no doctype at all.
Upvotes: 1