Skip to content

element-permitted-content

Reports an element that its parent does not permit as content (<li> outside a list, <div> in a <table>, a deprecated element in flow content), and one that an ancestor forbids as a descendant (<a> in <a>, a block element in a <button>).

The browser repairs invalid nesting on its own, and the repair moves or splits elements (a <div> in a <table> is moved out). The page then differs from the markup and from what scripts and styles select.

To fix, move the element to a parent that permits it, or use an element that fits.

Reported
...
<html lang="en">
...
<body>
<ul><li>a</li><div></div></ul>
<p><a href="x"><a href="y">z</a></a></p>
<font>old</font>
...
<a href="x"><img alt="logo" src="a"></a>
...
angular:
lint:
rules:
element-permitted-content: warn # off (default), warn, error
html:
lint:
rules:
element-permitted-content: warn # off (default), warn, error
svelte:
lint:
rules:
element-permitted-content: warn # off (default), warn, error
vue:
lint:
rules:
element-permitted-content: warn # off (default), warn, error

Enabled by the presets: html/html-validate-standard.

Suppress one line with sudsy-disable-next-line element-permitted-content in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-validate element-permitted-content partial the content model of html-validate (data/model.txt); elements that no model row names are not judged