Introduction to Units

Become familiar with CSS units before we take a look at each type in detail.

A CSS unit determines the size of a property we’re setting on a page element.

We can define the padding on a paragraph to be 10px, like so:

p {
  padding: 10px;
}

The value 10px includes the CSS unit px for pixel.

Is px the best unit to use? What about em, rem, or vw?

Let’s find out!

Get hands-on with 1200+ tech skills courses.