Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Units and Values

The fr unit

Reference for the CSS fr unit: how flexible fractions share leftover grid space, how minmax() and auto interact with it, and common mistakes.

The fr unit is a flexible length used only for grid tracks. One fr is a share of the space left over in the grid container after fixed-size tracks and gaps have been subtracted. Two tracks of 1fr split the leftover space equally; a 2fr track gets twice as much as a 1fr track.

Because fr is not a normal length, it works in grid-template-columns, grid-template-rows, grid-auto-columns, grid-auto-rows and inside minmax() and repeat(), but not in width, margin or calc().

CSS
.layout {
  display: grid;
  grid-template-columns: 200px 1fr 2fr;
}

Try it

Sharing leftover space

Syntax

CSS
<flex> = <number [0,โˆž]>fr

Initial value, inheritance and animatability depend on the property that uses it (for example grid-template-columns). The fr unit itself has no computed value outside a track list.

Values

Value Description
1fr One share of the free space.
2.5fr Fractions are allowed; the number must not be negative.
0.5fr If all flex factors in a track list add up to less than 1, the tracks use only that fraction of the free space and the rest stays empty.

Usage notes

  • 1fr means minmax(auto, 1fr). The automatic minimum is the content's minimum size, so a track with a long word or wide image can grow beyond its fair share. Write minmax(0, 1fr) when you need strictly equal tracks.
  • Fixed tracks come first. Pixel, %, auto and content-sized tracks and the gaps are resolved before fr shares the remainder.
  • Needs a definite size to share. In a row direction with an indefinite height, fr rows fall back to content size.
  • Ratios, not percentages. 1fr 3fr is a 1:3 split of the free space, not 25% and 75% of the container.
  • Not usable in calc(). calc(1fr + 10px) is invalid. Use minmax() or a fixed track plus 1fr instead.
  • Flexbox is different. Flex items are sized with flex-grow, not fr.

Browser support

Supported in all current browsers for grid layouts.