keyword

Subgrid — CSS reference

Makes the nested grid reuse the tracks it spans in the chosen axis, rather than defining independent sizes. Line numbers are local to the subgrid. The other axis may remain independent, and descendant contributions can influence the parent. Use a conventional nested grid fallback if support is uncertain.

Formal Syntax & Structure

css syntaxcss
grid-template-columns: subgrid;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>subgrid</title><style>body{margin:0}#g{display:grid;width:300px;grid-template-columns:100px 1fr;grid-auto-rows:40px;justify-content:start;align-content:start;background:#e8edf1}#g>*{background:#126f70;color:white}#b{background:#325d8c}#g{grid-template-columns:70px 110px 100px;gap:10px}#a{display:grid;grid-column:1 / 3;grid-template-columns:subgrid}#x,#y{background:#135a72}</style><body><div id="g"><div id="a"><div id="x">X</div><div id="y">Y</div></div><div id="b">B</div></div></body></html>
CSS Reference