concept

Grid percentage tracks — CSS reference

A track percentage refers to the container’s inner size in that axis. If that size depends on its tracks, the percentage is treated as auto for intrinsic sizing and resolved in final layout against the resulting size; this can create overflow. This fixture tests the simpler definite-width case.

Formal Syntax & Structure

css syntaxcss
grid-template-columns: 40% 1fr;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>grid-percentage-tracks</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:40% 1fr;gap:10px}</style><body><div id="g"><div id="a">A</div><div id="b">B</div></div></body></html>
CSS Reference