...

/

CSS Units and Viewport

CSS Units and Viewport

Learn CSS units and viewport measurements for consistency across devices.

Relative units and viewport measurements are essential for creating layouts that can adapt to different devices. In this lesson, we’ll discuss using percentages (%), em, rem, vw, and vh units in CSS. We’ll also explore absolute and relative units, discuss how to choose the appropriate units for different scenarios, and learn how to combine units using the calc() function.

Absolute units

Absolute units are fixed and do not change based on other elements or user settings. They are useful when we need precise control over the size of an element, regardless of the user's environment.

Pixels

Pixels are the most commonly used absolute unit in CSS. One pixel represents one dot on the screen.

Access this course and 1400+ top-rated courses and projects.