Skip to main content

CSS Unit

  • %

Percentage adjusts size relative to its parent.

For font-size, 150% means one and a half times larger than the parent's font size.

  • em

Em adjusts size relative to its parent's font size.

So, 2em means twice as big as the parent's font size.

  • rem

Rem adjusts size based on the root element's font size.

  • px

Pixels provide an exact size on the screen.

  • vh

Vh adjusts size based on the height of the viewport (visible area)

  • vw

Vw adjusts size based on the width of the viewport.