Most CSS properties require a unit, for example padding: 10px
. If you use 0
you can omit the unit, like padding: 0
.
An exception is the calc()
function, which always requires a unit, even for 0
.
.example-class {
padding: 0; /* works */
height: calc(100vh - 0); /* does NOT work */
height: calc(100vh - 0px); /* works */
}
That is mainly important if you use CSS custom properties (aka variables) with a default value of 0
inside calc()
:
.example-class {
height: calc(100vh - var(--header-height, 0)); /* does NOT work */
height: calc(100vh - var(--header-height, 0px)); /* works */
}