CSS: Default Unit

By Xah Lee. Date: . Last updated: .

CSS doesn't have a default unit. Omitting unit is syntax error.

/* WRONG */
div.x {width:400}

you have to write:

div.x {width:400px}

But if it is 0, then no unit is necessary.

List of CSS Units

CSS: Units

JS in Depth
XAH  BUY NOW

CSS

Basics

Color

Font

Text Decoration

Box Model

Box Decoration

Layout

Layers

Transform/Animation

Line Wrap

Misc