concept
Dense grid packing — CSS reference
Dense auto-placement searches earlier available holes when placing later items. It can improve packing but may change the visual sequence. Keep meaningful reading and keyboard order in the source; dense packing does not rewrite the DOM.
Formal Syntax & Structure
css syntaxcss
grid-auto-flow: row denseWorking Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Dense grid packing</title><style>body{margin:0}#g{display:grid;width:300px;grid-template-columns:100px 100px 100px;grid-template-rows:40px 40px;grid-auto-flow:row dense;}#g>*{background:#146e73;color:white;box-sizing:border-box}#b{background:#345d8e}#c{background:#79518e}</style><body><div id="g"><div id="a" style="grid-column:span 2">A</div><div id="b" style="grid-column:span 2">B</div><div id="c">C</div></div></body></html>