• Tutorials Logic, IN
  • +91 8092939553
  • info@tutorialslogic.com

CSS Units

Units

Units in CSS allow us to set the size of a CSS property for an element or its content using several different units. There are mainly two categories of units available in CSS, which are given below-

Absolute Lengths:- The absolute length units are fixed and it is same for different sizes of screen layout. It is recommended to use where responsiveness is not being considered (i.e. print layout and where the output medium is known).

Absolute Length UnitDescription
px1px = 1/96th of 1in
pt1pt = 1/72 of 1in
pc1pc = 12 pt
cmcentimeter
mmmillimeter (10mm = 1cm)
in1in = 96px = 2.54cm

Relative Lengths:- The relative length units are useful for styling responsive web page, because they scale relative to the parent or window size.

Relative Length UnitDescription
%It is relative to the parent element.
emIt is relative to the current font-size of the element.
remIt is relative to font-size of the root element (i.e. <html>).
chIt is relative to width of the zero.
vhIt is relative to the height of the viewport (1vh = 1/100 of the viewports height).
vwIt is relative to the width of viewport (1vw = 1/100 of the viewports width).
vminIt is relative to viewports smaller dimension (1vmin = 1/100 of viewports smaller dimension).
vmaxIt is relative to viewports larger dimension (1vmax = 1/100 of viewports larger dimension).
exIt is relative to the x-height of the current font.
										    
											p {
												font-size: 16px;
												line-height: 2.5em;
											}