Linter Rule: Disallow unknown HTML tags
Rule: html-no-unknown-tag
Description
Disallow HTML elements that are not part of the HTML Living Standard. Non-standard tags like <hello> or <foo> are almost always typos or mistakes and should be flagged.
Rationale
Browsers will render unknown HTML elements as inline elements with no special behavior, creating an HTMLUnknownElement instance. This is rarely intentional and usually indicates a typo or a misunderstanding of the available HTML elements.
Custom elements (tags containing a hyphen, like <turbo-frame> or <my-component>) are valid per the Web Components specification and are always allowed.
This rule also checks Action View tag helpers like <%= tag.hello %>, since the parser resolves these to their corresponding HTML elements. Note that tag.my_component is automatically translated to <my-component> by Rails and will not trigger this rule.
Examples
✅ Good
<div></div>
<span></span>
<section></section>
<img src="logo.png" alt="Logo"><turbo-frame id="messages"></turbo-frame>
<my-component></my-component><Button></Button><UI::Button></UI::Button><svg viewBox="0 0 24 24">
<path d="M0 0h24v24H0z"></path>
<circle cx="12" cy="12" r="10"></circle>
</svg><math>
<mrow><mi>x</mi><mo>=</mo><mn>1</mn></mrow>
</math><%= tag.div do %>content<% end %>
<%= tag.my_component do %>content<% end %>🚫 Bad
<hello></hello><foo></foo><my_component></my_component><%= tag.hello do %>content<% end %>