<?xml version="1.0" encoding="utf-8"?>

The font size property

The font size property

Many CSS properties allow for different value types, and the font-size value is no different. The easiest way is to define your text's size is to use pixels px — an absolute unit that always remains the same no matter what.

But if you will be changing the document's default font size, you probably want all your elements to stay proportionate to one another. That's where relative units em and rem come into play, being equal to the font size of the parent and root element (<HTML>), respectively. For example, if you set a <h1 style=" font-size: 2rem;">, your headings will always be twice as big as the body text, no matter what text size you set on the document.

Top contributors

Valentina Wickham

Topics

From Lesson

Share

Improve your UX & Product skills with interactive courses that actually work