Skip to main content

no-unescaped-char

Warns when a literal < appears unescaped in a text node or attribute value. HTML Living Standard §13.1.2.3–4 requires authors to escape a literal < and an "ambiguous ampersand" — everything else (>, ", and a bare & that isn't shaped like a reference attempt) is conforming as-is.

A &name;-shaped sequence with an unrecognized name is no-malformed-character-reference's concern, not this rule's — it mirrors parse5's own detection of that case.

❌ Examples of incorrect code for this rule

<div id="a"> < </div>

✅ Examples of correct code for this rule

<div id="a"> &lt; </div>
<div id="a"> > & " </div>
<img src="path/to?a=b&c=d">

Interface

{
"no-unescaped-char": boolean
}

Options

{
"no-unescaped-char": {
"options": {
"strict"?: boolean
}
}
}
PropertyTypeDefault ValueDescription
strictboolean"false"Also flag >, ", and every bare & (entity-shaped sequences like &amp; are still exempt). Off by default because HTML LS only prohibits a literal < and an ambiguous ampersand unescaped — > and " are conforming as-is.

Default Severity

error

Details

Setting strict option

When true, also flags >, ", and every bare & (an entity-shaped sequence like &amp; is still exempt either way). Off by default.

{
"no-unescaped-char": {
"options": {
"strict": true
}
}
}

❌ Examples of incorrect code with strict: true

<div id="a"> > < & " </div>
<img src="path/to?a=b&c=d">