Skip to content

color-no-invalid-hex

Reports a hex color that does not have 3, 4, 6 or 8 digits (#ab).

CSS accepts only those lengths, so the declaration is invalid and the browser drops it, and the element is left with the inherited or default color.

To fix, correct the number of digits.

Reported
...
border-color: #ab #abcde #abcdef;
...
css:
lint:
rules:
color-no-invalid-hex: warn # off, warn (default), error
less:
lint:
rules:
color-no-invalid-hex: warn # off, warn (default), error
scss:
lint:
rules:
color-no-invalid-hex: warn # off, warn (default), error

Enabled by the presets: css/stylelint-recommended.

Suppress one line with sudsy-disable-next-line color-no-invalid-hex 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 color-no-invalid-hex full