What is the Relative size?

Relative size sets the size relative to surrounding elements. Allows a user to change the text size in browsers.

The default size for normal text, like paragraphs, is 16px (16px=1em).

To avoid the resizing problem, we cau use em instead of pixels. 1 em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px.

The size can be calculated from pixels to em using this formula: pixels/16=em.

h1 {font-size:2.5em;} /* 40px/16=2.5em /
h2 {font-size:1.875em;} /
30px/16=1.875em /
p {font-size:0.875em;} /
14px/16=0.875em */