Skip to main content

Sizes and Units

Which will the % (percentage) value calculated in reference to? The answer depends on the position property of the html element and the containing block (container), which the element takes as reference, for calculation of percentage.

3 Rules to Remember:

3 Rules to Remember for Sizes and Units

The Containing Block

  • The reference point when applying % units to an element
  • Depends on the position property applied to this element
  • Can be the closest ancestor or the viewport

Which unit(px, rem, etc.) should I choose?

Which CSS unit should I choose