Bugzilla – Bug 764
p tag errors
Last modified: 2010-09-20 02:26:32 CEST
Get error: No p element in scope but a p end tag seen. <section id="express-box"> <header> <h2><b>Klum</b>men</h2> </header> <p><!-- p tag set --> Kompetencer... <ul> <li>HTML / XHTML / HTML5</li> <li>CSS</li> <li>JavaScript</li> <li>PHP</li> <li>MySQL</li> </ul> </p><!-- this p tag gets an error --> <blockquote><p>Touch the book - lick the book...</p></blockquote> </section>
This is expected behavior. If you want to avoid it, you should use a <div> element there instead of a <p>. Because a <ul> element is not valid as a child <p> element. So the reason you see that message is, the HTML parser is closing that <p> element before the <ul> element. That's what the HTML parsing algorithm says it must do: The <ul> start tag "implies" to the parser that it must close any open <p> elements. So, when the parser subsequently finds the </p> end tag later in the tree, it reports an error because it no longer has any <p> element open ("in scope").
btw, if you want to examine how your browser actually parses that document fragment, you check that here: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/639