Skip to content

What is the unit rem in css?

Published:

A px is a pixel, a cm a centemeter and a in an inch. When I define styles in css i can use any of these units to set a size or fontsize.

All these units I called in the first block are absolute lenghts. But there are also relative lengths you can use in css. One of the easiest examples for a realtive lenght is percent. You can use % in css to define a length relative to it’s parent element.

But what is rem? rem is a relative length and refers to the root elements font size. So if you have set a font size of 30px in your root element 1rem in css is 30px and gives you the same font size. 2rem is quite big and could be use for a headline or something else.