In IE10, I create the following web page, and get an unmatched tag error:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p>
<div>
</div>
</p>
</body>
</html>
I can find no problem with this code. I have narrowed it to having a div inside a paragraph as what is triggering the problem. IE10 reports:
HTML1509: Unmatched end tag.
test.php, line 12 character 2
and is pointing to the paragraph close token. An earlier me might have just ignored it. But I can't make myself do that any more.
I have searched this site for something similar, but have found only legitimate syntax errors; valid explanations for the error, in other words. I know IE is brain-dead, but even post-Bill MSFT can't be silly enough to let a bug like that one, through (can they?). So I am assuming it's me, until proven otherwise. Possibly some subtlety of HTML5 I haven't grokked yet...
You can't have DIV (or any other block element) in a P unless you serve your markup as application/xhtml+xml. All pages served as text/html are parsed by HTML parser (in modern browsers, including IE10, it's HTML5 parser, regardless the doctype). In HTML, the content model of P element is 'phrasing content' (HTML5) or 'inline' (HTML4), and its end tag is optional in all versions of HTML. So the parser implicitly closes the P element before the opening tag of any block element. And in all browsers the DIV element will be not the child of P, but the sibling, and CSS selectors like p > div will never work for pages served as text/html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With