Before we start the actual exercise, we would like to give a brief idea about the CSS Measurement Units. In CSS, different types of measurements are used. By the help of these measurements, we can perform various operations with different formats on HTML elements. We are going to show various measurement units on the below page.

UnitDescriptionExample
%Defines a measurement as a percentage relative to another value, typically an enclosing element.p {font-size: 16pt; line-height: 125%;}
cmDefines a measurement in centimeters.div {margin-bottom: 2cm;}
emA relative measurement for the height of a font in em spaces. Because an em unit is equivalent to the size of a given font, if you assign a font to 12pt, each “em” unit would be 12pt; thus, 2em would be 24pt.p {letter-spacing: 7em;}
exThis value defines a measurement relative to a font’s x-height. The x-height is determined by the height of the font’s lowercase letter x.p {font-size: 24pt; line-height: 3ex;}
enDefines a measurement in inches.p {word-spacing: .15in;}
mmDefines a measurement in millimeters.p {word-spacing: 15mm;}
pcDefines a measurement in picas. A pica is equivalent to 12 points; thus, there are 6 picas per inch.p {font-size: 20pc;}
ptDefines a measurement in points. A point is defined as 1/72nd of an inch.body {font-size: 18pt;}
pxDefines a measurement in screen pixels.p {padding: 25px;}
CSS Measurement Unit Table

Share post

Leave a Reply