Question
What is a pixel and is this the only measure of font size?
Answer
A pixel is one of several units of measure in web development. It is an absolute unit equal to 1/96 of an inch.
Rems and ems are scalable typographic units which are commonly used with the font-size
property. As opposed to pixels, both of these units are relative. For example, an em is measured relative to the font-size
of an element. When dealing with ems it is important to realize that the font-size
of an element is often inherited from an ancestor element. On the other hand, rems are determined based on the font-size
of the html
element. If font-size
is not defined on the html
element, the browser’s default font-size
is used instead (usually 16px).
There are pros and cons of each unit but one major advantage of using relative units is that they lend themselves more naturally to responsive design. Relative units like ems and rems are flexible and scalable whereas pixels are not.