Skip to content

length-zero-no-unit

Reports a zero length written with a unit (0px). Dimensions that are not lengths (0s, 0deg), and anything inside a function, are not reported.

Zero is the same in every length unit, so the unit says nothing and costs bytes. Inside calc() and the like the unit may be needed, so those are left alone, as are times and angles, where a unit is required.

To fix, write 0.

Reported
...
@import "b.css";
a {
margin: 0px 0.0em 0;
transition: 0s;
width: calc(0px + 1px);
--x: 0px;
...
css:
lint:
rules:
length-zero-no-unit: warn # off (default), warn, error
less:
lint:
rules:
length-zero-no-unit: warn # off (default), warn, error
scss:
lint:
rules:
length-zero-no-unit: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line length-zero-no-unit 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 length-zero-no-unit full