Skip to content

selector-max-id

Reports a selector with more id selectors than the max option.

An id adds more specificity than any number of classes, so a rule with ids can only be overridden by another id or by !important. A limit (often 0) keeps the specificity of a project flat.

Reported
.a.b.c, #x #y, a b c d, [p][q], * *, a:hover:focus { color: red }
...
.i {
...
css:
lint:
rules:
selector-max-id:
level: warn # off (default), warn, error
options:
max: 0
less:
lint:
rules:
selector-max-id:
level: warn # off (default), warn, error
options:
max: 0
scss:
lint:
rules:
selector-max-id:
level: warn # off (default), warn, error
options:
max: 0
Option Type Default Description
max int 0 The most ids a selector may have.

Suppress one line with sudsy-disable-next-line selector-max-id in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint selector-max-id full