What’s the main difference between pixel(px) and rem? And when should I use px over rem?
Asked
Active
Viewed 2,011 times
1 Answers
0
Pixels are an absolute unit. This means that a heading that has the font-size 30px
always has exactly this size, namely 30 pixels. No matter what happens around it.
You can only tell how big a heading is that is specified in 2.3em when you know what environment it is in. This is because the unit em refers to the next higher container.
The unit rem is identical to the unit em, but the element to which this unit refers is the root element, i.e. the html element.

Maik Lowrey
- 15,957
- 6
- 40
- 79