CSS has several units for different units such as width, margin, padding, font-size, border-width, etc. The 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 divided as follows:
- relative units
- absolute
Absolute 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 the element
Units | Abbreviation |
---|---|
Percent | % |
Em | Em |
Ex | Ex |
Root em | Rem |
Viewport width | Vw |
Viewport width | Vh |
Viewport width | Vm |
Character | Ch |
Grid | Gd |