Sizes in CSS

CSS language uses different measurement units and, for texts, you can use only one or many of them combined. As for relative ones, their final size will vary according to the preceding CSS set of instructions.

The units are:

px (pixels, absolute)
pt (points, absolute)
pc (about 12 points, absolute)
in (inch, absolute)
cm (centimetre, absolute)
mm (millimetre, absolute)
em (current font size, relative)
ex (about half of the size of the font, relative)
% (percentage, relative)

By the way, the most commonly used units are px, pt, % and em.

How to write it

To use CSS instructions correctly, you only need to specify the units without spaces, like in the following examples. Decimals and negative values are also valid:

Examples

80%
468px
12pc
1in
27cm
120mm
0.88em
1.2ex
69%

It is very easy.


Knowledge + Computers