Units in grid

Apart from the basic CSS units (px, em, rem, vh, vw...), these are the most commonly used units in CSS grid:
  • fr: fraction of the available space.
  • %: relative to the container.
  • auto: size based on content.
  • min-content / max-content: adjusts to the minimum or maximum content size.
  • span: allows an element to span multiple rows or columns based on the specified number.

Example

In this example, we show a series of columns with each of these units, where we can visualize the behavior of each one.

ResultLive
html
css