Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Omit the unit on a zero length in CSS
Write `0`, not `0px`/`0rem`/`0em`, for zero lengths. Zero is unitless in CSS and the unit adds noise. (Keep the unit only where a unit is required, e.g. some `calc()` operands and angle/time zeros.)
Bad example
| 1 | .box { margin: 0px; padding: 0rem 12px; } |
Explanation (EN)
A unit on an ordinary zero length adds no information.
Objašnjenje (HR)
Good example
| 1 | .box { margin: 0; padding: 0 12px; } |
Explanation (EN)
Bare 0 is shorter and idiomatic.
Objašnjenje (HR)
Notes (EN)
For a plain literal zero where the property grammar accepts a length, omit its length unit while preserving the surrounding shorthand values.
Exceptions / Tradeoffs (EN)
Keep units where typed calculations require them, and do not apply the rule to angle/time zeros, custom-property token contracts or preprocessing helpers without checking their grammar.