validator / validator

Nu Html Checker – Helps you catch problems in your HTML/CSS/SVG
https://validator.github.io/validator/
MIT License
1.68k stars 270 forks source link

Report more-helpful message for *No p element in scope but a p end tag seen* #486

Open evanorsouw opened 7 years ago

evanorsouw commented 7 years ago

When checking the site whitemagic.it the following error is reported;

Error: No p element in scope but a p end tag seen. From line 117, column 17; to line 117, column 20

It appears this is an invalid error.

sideshowbarker commented 7 years ago

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 open p elements.

cvrebert commented 7 years ago

I 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.

evanorsouw commented 7 years ago

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.

cvrebert commented 7 years ago

Erm, Michael was the one who diagnosed your problem.

evanorsouw commented 7 years ago

ah yeah, my bad, thanks michael.