Skip to content

valid-id

Reports an id that is empty, has white space, begins with a digit or has characters other than letters, digits, - and _.

Such an id is valid HTML5, but it must be escaped in CSS selectors (#1a does not select it) and some scripts and older tools fail on it.

To fix, rename the id.

Reported
<!DOCTYPE html>
<title>x</title>
<p id="1a"></p>
<p id="a b"></p>
<p id="a-b_c"></p>
<p id=""></p>
...
<label for="y">y</label><input type="text" id="y">
...
angular:
lint:
rules:
valid-id: warn # off (default), warn, error
html:
lint:
rules:
valid-id: warn # off (default), warn, error
svelte:
lint:
rules:
valid-id: warn # off (default), warn, error
vue:
lint:
rules:
valid-id: warn # off (default), warn, error

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

Suppress one line with sudsy-disable-next-line valid-id 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 valid-id partial the strict form only, without the relaxed option