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

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc