From the course: CSS for Developers
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Units and sizes - CSS Tutorial
From the course: CSS for Developers
Units and sizes
- [Instructor] CSS offers support for many units of measurement. These are what you use to define heights and widths for things like block level elements, padding, margins, font sizes, et cetera. Some of these units are absolute or fixed length, while others are relative. I'm going to limit our discussion here to the most common ones you'll use as you work with CSS. First, we have pixels. These are referred to as an absolute length, and just like an inch of space takes up a physical amount of room, so does a pixel. For instance, if a font size is set to 16 pixels, then a single glyph will be 16 pixels tall. This is the single most common absolute length you'll see in use. Next, we have ems. Unlike pixels, these are relative lengths, and they're relative to the font size of a parent element. Let's say you have a parent container set to a 20 pixel font size, that is then equal to 1em. 2ems would be 40 pixels and so on. From there, you could set your paragraphs to 1em, maybe your…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.