htmlhint / HTMLHint

⚙️ The static code analysis tool you need for your HTML
https://htmlhint.com
MIT License
3.08k stars 380 forks source link

self-closed custom-element do not fail. #142

Closed MeirionHughes closed 4 years ago

MeirionHughes commented 8 years ago

https://www.w3.org/TR/html-markup/syntax.html#syntax-elements

A non-void element must have an end tag, unless the subsection for that element in the HTML elements section of this reference indicates that its end tag can be omitted.

So custom tags webcomponents must have an end tag and cannot self-close.

example htmlhint --rules tag-pair

<custom-element attribute="value"/>

should fail in htmlhint (currently does not)

<custom-element attribute="value"></custom-element>

should pass in htmlhint (currently does)

joeskeen commented 8 years ago

+1

I also found this which is useful:

The following is a complete list of the void elements in HTML: area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr

https://www.w3.org/TR/html-markup/syntax.html#syntax-elements

Currently HTMLHint doesn't complain if you self-close any element. We had an issue in one of our projects where there was a self-closing textarea which caused some really weird behavior during minification and runtime.

Thus it would be great if we could have a rule that would cause a warning for any self-closing tag that isn't in the list of void tags above.

schmod commented 7 years ago

Just wanted to say that we've had a similar issue, where htmlhint failed to correctly mark <div /> as invalid.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.