Error Length value missing a unit
Why margin: 10 is invalid CSS while margin: 0 is fine, and the full list of length properties that require a unit on any non-zero value.
The validator flags a bare number (no px, rem, %, or other unit) on a length property, unless the value is exactly 0.
Example
/* Wrong: no unit */
.box { margin: 10; padding: 5; }
/* Right */
.box { margin: 10px; padding: 0.5rem; }
/* Fine: zero never needs a unit */
.box { border-width: 0; }Why it matters
CSS length values require a unit for any non-zero number — this is one of the few places the spec makes zero a genuine special case, since a length of zero is the same regardless of unit. A bare number like 10 on a property like margin is not valid CSS, and the browser drops the entire declaration rather than guessing which unit you meant. This is a common mistake coming from JavaScript or other languages where a numeric style value is often set without a unit — many DOM APIs and CSS-in-JS libraries add px automatically, which can make the omission feel natural in a way it isn't in plain CSS.
Frequently asked questions
Why is 0 an exception?
A length of zero is the same physical distance no matter what unit it's measured in — 0px, 0rem, and 0% are all identical — so the CSS spec allows the unit to be omitted specifically for zero. Any non-zero number still needs one.
Which properties does this check apply to?
Common length properties — margin, padding, width, height, positioning offsets (top/right/bottom/left), font-size, border widths, border-radius, gap, and a few similar ones. It intentionally skips properties that are legitimately unitless, like line-height, z-index, and opacity.