Skip to Content
CSS in Depth
book

CSS in Depth

by Keith Grant
March 2018
Intermediate to advanced content levelIntermediate to advanced
472 pages
13h 5m
English
Manning Publications
Content preview from CSS in Depth

Chapter 2. Working with relative units

This chapter covers

  • The versatility of relative units
  • How to use ems and rems, without letting them drive you mad
  • Using viewport-relative units
  • An introduction to CSS variables

When it comes to specifying values, CSS provides a wide array of options to choose from. One of the most familiar, and probably easiest to work with, is pixels. These are known as absolute units; that is, 5 px always means the same thing. Other units, such as em and rem, are not absolute, but relative. The value of relative units changes, based on external factors; for example, the meaning of 2 em changes depending on which element (and sometimes even which property) you’re using it on. Naturally, this makes relative units more ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

CSS: The Definitive Guide, 4th Edition

CSS: The Definitive Guide, 4th Edition

Eric Meyer, Estelle Weyl
Tailwind CSS

Tailwind CSS

Ivaylo Gerchev

Publisher Resources

ISBN: 9781617293450Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link