Subgrid and intrinsic contributions
Definition and purpose
Subgrid makes a nested grid reuse the parent tracks on a chosen axis instead of calculating independent tracks there. A subgrid spanning two parent columns has two shared column tracks; its descendants can influence the parent intrinsic track sizing on that axis.
Shared auto track
<!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; font: 16px sans-serif; color: #172033; background: white; } #parent { display: grid; width: 300px; grid-template-columns: auto 1fr; gap: 10px; } #group { display: grid; grid-column: span 2; grid-template-columns: subgrid; } #a { width: 100px; } #c { min-width: 0; } #a, #b, #c, #d { background: #dbeafe; } </style> </head> <body> <div id="parent"> <div id="group"> <div id="a">A</div> <div id="b">B</div> </div> <div id="c">C</div> <div id="d">D</div> </div> </body></html>The nested 100px probe determines the shared auto column.
Syntax and mental model
Here the parent has auto and 1fr columns with a 10px gap. The subgrid child A is 100px wide and contributes to the parent auto column. The remaining 190px belongs to the second column. Both B inside the subgrid and D outside it begin at x=110px. If A becomes 140px, both second-column starts move to 150px. A nested independent grid using equal fractions would not share these lines. The axis not subgridded can still have its own implicit tracks; on the subgridded axis additional implicit tracks cannot extend its inherited span.
Larger nested contribution
<!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; font: 16px sans-serif; color: #172033; background: white; } #parent { display: grid; width: 300px; grid-template-columns: auto 1fr; gap: 10px; } #group { display: grid; grid-column: span 2; grid-template-columns: subgrid; } #a { width: 100px; } #c { min-width: 0; } #a, #b, #c, #d { background: #dbeafe; } #a { width: 140px; } </style> </head> <body> <div id="parent"> <div id="group"> <div id="a">A</div> <div id="b">B</div> </div> <div id="c">C</div> <div id="d">D</div> </div> </body></html>A wider nested child moves both second-column starts.
Common mistakes
Do not confuse subgrid with display: contents; the subgrid element still has a box. Its margins, padding, borders and gap differences can affect contributions. Keep a usable independent-grid fallback and verify support with @supports where needed.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Grid track sizing algorithm. Next lesson: Font face and loading strategy.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Subgrid and intrinsic contributions — knowledge check
Five questions on subgrid and intrinsic contributions.
What is shared by a column subgrid?
Can a nested child affect parent intrinsic sizing?
Where do B and D start with A width 120px and gap 10px?
Does subgrid remove the nested element box?
Can implicit tracks extend a subgridded axis beyond its span?