What are different types of CSS units?

What are different types of CSS units?

Hi Emma,

In CSS, you have a variety of units to define sizes and positions. Here’s a breakdown of the main types:

1. Absolute Units:

  • Pixels (px)
  • Centimeters (cm), Millimeters (mm), Inches (in)
  • Points (pt)

2. Relative Units:

  • Em (em)
  • Rem (rem)
  • Percentages (%)
  • Viewport Units (vh, vw)

Learn more about the above CSS units in detail. Check out this article

CSS units are relative to the viewport’s size. vmin is relative to the viewport’s smaller dimension, while vmax is relative to the larger dimension. They are useful for creating responsive designs that adapt to different screen sizes.

The fr unit in CSS Grid Layout represents a fraction of the available space in the grid container. It allows you to create flexible and responsive layouts without having to use complex calculations or fixed values.