Skip to content

color-hex-length

Reports a hex color that can be written with three or four digits (#aabbcc). With the style option set to long, a color written short is reported instead.

One length for hex colors keeps a file uniform, and the short form is the usual one: it is half the bytes and still unambiguous.

To fix, shorten each pair of equal digits to one.

Reported
...
width: calc(0px + 1px);
...
color: #aabbcc;
...
css:
lint:
rules:
color-hex-length:
level: warn # off (default), warn, error
options:
style: "short"
less:
lint:
rules:
color-hex-length:
level: warn # off (default), warn, error
options:
style: "short"
scss:
lint:
rules:
color-hex-length:
level: warn # off (default), warn, error
options:
style: "short"
Option Type Default Description
style string "short" short reports colors that can be shortened, long those that are short.
Values: short, long

Enabled by the presets: css/stylelint-standard.

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