CSS - Units


Advertisements


CSS Units

CSS has several units for different units such as width, margin, padding, font-size, border-width, etc.length indicates by using numerical value followed by length units such as px,dp,em,etc. It does not allow white spaces in between numerical values and length units.Length units has divided as follows

  • relative units
  • absolute

Relative units

A length is relatively each others to another length property is called as relative length units

Units Abbreviation
Pixels px
Points pt
Inches in
Centimeters cm
Picas pc

Relative Units

In relative units, the length value is fixed and it appears the exact size of element

Units Abbreviation
Percent %
Em em
Ex ex
Root em rem
Viewport width vw
Viewport width vh
Viewport width vm
character ch
Grid gd


Advertisements