Repository navigation
Report more-helpful message for *No p element in scope but a p end tag seen* #103
Description
Activity
Please post the source of a document or document fragment that causes this error to be emitted
Mostly likely this is reported because the document has something like this:
<p> <ul> … </ul> </p>In that case what that document really looks like, as seen by an HTML parser, is this:
<p></p> <ul> … </ul> </p>That’s because, the way HTML works is, a
<ul>start tag implies a</p>close tag for any openpelements.Reacted by Thorisho and aynaderI feel like a FAQ for "p was implicitly closed by open tag of element disallowed by p's content model, thus making the explicit p close tag unmatched" is merited at this point. It seems to come up frequently on the issue tracker. Maybe with a link to other linter(s) that give more comprehensible error messages in that case.
Chris, you hit the spot right on.
<p><ul></ul></p>is exactly what the html looks like.
I guess there is a lot of html legacy at play, so I am fine with your explanation.
Your suggestion to somehow improve the error message seems valid to prevent wasting time in the future as much as possible.
Thx for the swift response.Erm, Michael was the one who diagnosed your problem.
ah yeah, my bad, thanks michael.
- changed the title
[-]Invalidly reporting mismatching element[/-][+]Report more-helpful message for *No p element in scope but a p end tag seen* [/+]on Mar 31, 2017 Hi there! I also encountered an error during validation related to the
element. I received the same error with the following structure:
<!DOCTYPE html> <html lang=""> <head> <title>abc</title> </head> <body> <p> <p> </p> </p> </body> </html>
I used this validator to test the content: https://validator.w3.org/nu/#textarea
I also tested the resulting DOM structure in Firefox, Safari, and Chrome. In all cases, the browsers automatically inserted missing start/end tags, modifying the structure. Additionally, Firefox showed an error for the last
</p>tag in "View source" mode.Results in browsers
<!DOCTYPE html> <html lang=""> <head> <title>abc</title> </head> <body> <p></p> <p></p> <p></p> </body> </html>
According to the p element documentation, when a new
<p>tag appears inside an open<p>, the first one is automatically closed. This automatic closing causes the second</p>to generate an error during validation.I wanted to share this here in case it helps someone else encountering the same issue.
When checking the site whitemagic.it the following error is reported;
It appears this is an invalid error.