Deep Dive into Web Dev

Web Dev

Deep dive into relative units in CSS

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. 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 difficult to work with. The way the value of an em can change makes it seem unpredictable and less clear-cut than the pixel.
7 min read
Deep dive into relative units in CSS