property

grid — CSS reference

Shorthand for the explicit template and implicit track sizing and auto-flow properties. Omitted components reset to initial values. It does not reset gap or alignment. Use the template form for a fixed layout or an auto-flow form to specify how missing tracks are generated.

Formal Syntax & Structure

css syntaxcss
<grid-template> | <explicit-rows> / [ auto-flow && dense? ] <implicit-columns>? | [ auto-flow && dense? ] <implicit-rows>? / <explicit-columns>

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>grid</title><style>body{margin:0}#g{display:grid;grid-auto-rows:99px;grid:40px / 100px 200px;}#g>*{background:#146e73;color:white;box-sizing:border-box}#b{background:#345d8e}#c{background:#79518e}</style><body><div id="g"><div id="a">A</div><div id="b">B</div><div id="c">C</div></div></body></html>
CSS Reference