Fractional tracks and minmax
Definition and purpose
The fr unit allocates a share of flexible grid space. Track minima and nonflexible tracks affect how much space is left, so a fractional track is not simply a percentage of the entire container.
Flexible track shares
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; } #p { width: 300px; } #p > div { background: lightblue; outline: 1px solid navy; } #p { display: grid; grid-template-columns: 1fr 2fr; gap: 30px; } </style> </head> <body> <div id="p"> <div id="a">A</div> <div id="b">B</div> <div id="c">C</div> </div> </body></html>After subtracting the gap, 270px is divided into 90px and 180px.
Syntax and mental model
minmax(minimum, maximum) specifies a track’s sizing range. In a definite 300px grid with 20px gap and columns 1fr 2fr, 280px remains before intrinsic minimum constraints. For minmax(0, 1fr) the explicit zero minimum can avoid a content-based track floor; internal overflow still needs handling.
Explicit minimum
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; } #p { width: 300px; } #p > div { background: lightblue; outline: 1px solid navy; } #p { display: grid; grid-template-columns: minmax(100px, 1fr) 1fr; gap: 20px; } </style> </head> <body> <div id="p"> <div id="a">A</div> <div id="b">B</div> <div id="c">C</div> </div> </body></html>Both tracks receive 140px, above the 100px minimum.
Common mistakes
Do not use fr as the minimum argument to minmax. A bare fr track has an automatic minimum; equal fr values do not guarantee equal widths when minima force a different result.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Tracks, lines, cells and areas. Next lesson: Explicit placement and named areas.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fractional tracks and minmax — knowledge check
Five questions on fractional tracks and minmax.
What does fr allocate?
Which minmax minimum is valid?
In a 300px grid with 30px gap and 1fr 2fr, ignoring minima, how wide is the second track?
What does minmax(0, 1fr) change compared with a bare 1fr?
Does a zero track minimum guarantee contents fit?