CSS TutorialLesson 41Free preview
CSS Units
This lesson is part of CSS · All levels
Summary
The CSS unit determines the value of a property such as font size, distance, and width. There are two main groups: absolute units such as px and pt that are fixed in size, and relative units such as em, brake, %, vw, and vh that adjust the context or screen size. The right selection of units makes the look consistent and responsive.
Key points
- Absolute units like px and pt are always the same size wherever used.
- Em is calculated relative to the font size of the element itself, brake relative to the font of the root element.
- % relative to the size of the host, whereas vw and vh relative to the viewport.
- The relative units make the layout more responsive to user preferences and screen size.
- Text-related units such as ch and ex are useful for ordering and measuring the letters.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.