CSS units determine the measurement of an element along with specific background field. These units include pixel(px), percentage(%), viewport height(vh) etc that defines the measurement of screen. With the help of these units, you can decide the size of your element and background.
The available units are -
- Px - Pixels are relative to the viewing device. For low-dpi devices, 1px is one device pixel (dot) of the display. For printers and high resolution screens 1px implies multiple device pixels.
- % - Relative to the parent element
- Vh - Relative to 1% of the height of the viewport*
- Rem - Relative to font-size of the root element
- Em - Relative to the font-size of the element (2em means 2 times the size of the current font)
*Viewport = the browser window size. If the viewport is 50cm wide then 1vw = 0.5cm