fr
A share of the free space in a grid track.
Safe to useBaseline: widely available
| Browser | Since |
|---|---|
| Chrome | 57+ |
| Chrome Android | 57+ |
| Edge | 16+ |
| Firefox | 52+ |
| Firefox Android | 52+ |
| Safari | 10.1+ |
| Safari iOS | 10.3+ |
Formula 1fr = one part of the space left after fixed tracks and gaps
How it works
Take a grid 500px wide with grid-template-columns: 100px 1fr 2fr and a 20px gap. The fixed column and the two gaps use 140px; the 360px that are left go to the fr columns at one part against two, so they measure 120px and 240px. fr is always worked out last, as a number of parts of whatever the fixed tracks and gaps have not used.
It is not a length you can use anywhere else. A property such as width rejects it outright. It is valid only where a grid track size is expected, which means the grid-template-* properties for the explicit tracks and the grid-auto-* properties for the implicit ones, including inside repeat() and as the maximum of minmax(). The number can be fractional, and a total below 1 behaves differently from what most people expect: 0.25fr 0.25fr in a 400px grid gives two 100px tracks and leaves half the container empty, because the fractions claim only their share of the free space.
In a 200px grid, a single 1fr column holding one word 120 letters long grew wider than the grid itself, because a plain 1fr means minmax(auto, 1fr) and the auto minimum is the content’s own smallest width. The same column written as minmax(0, 1fr) stayed at 200px and let the word overflow inside it instead. The floor, not the share, is what breaks grids: remove it with minmax(0, 1fr), then give the content a text-wrap or overflow rule for the day it does not fit.
Try it
fr against minmax(0, 1fr)
Three equal columns in a box 360px wide. Put a long word in the first one and see which track size gives way.
- Column 1
- Column 2
- Column 3
The same as a table
| grid-template-columns | Grid and gap | Track widths |
|---|---|---|
100px 1fr 2fr | 500px, 20px | 100px, 120px, 240px |
1fr 2fr | 300px, 0px | 100px, 200px |
0.25fr 0.25fr | 400px, 0px | 100px, 100px |
What changes it
- Moves with
- page zoom
- Stays put under
- the reader's text size
- the window size
- the font in use
- the query container
- phone toolbars
- the writing mode
And the free space of its own grid: every fixed track, gap and content minimum changes what is left to share.
Reach for it when
Grid columns that split the leftover width: a fixed sidebar next to a flexible main column.
Watch out
1fr has a hidden floor: the track never gets narrower than its content's smallest size, so a code block or a long URL widens the whole grid. minmax(0, 1fr) takes the floor away.
Before
.page-grid {
display: grid;
grid-template-columns: 14rem 1fr;
gap: 1.5rem;
}After
.page-grid {
display: grid;
grid-template-columns: 14rem minmax(0, 1fr);
gap: 1.5rem;
}