CSS Grid Layout
suggest changeCSS Grid is a two-dimensional layout system for arranging content in rows and columns. Use it for page regions, galleries, forms, dashboards, and other layouts where both axes matter.
.layout {
display: grid;
grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
gap: clamp(1rem, 3vw, 2rem);
}
Direct children become grid items. Unless positioned explicitly, they follow the grid auto-placement algorithm.
Modern Grid properties are unprefixed. Do not use the obsolete grid-columns, grid-rows, or -ms-grid-* syntax: those belong to an earlier, incompatible model.
Useful modern patterns include:
repeat()for repeated tracks;minmax()for flexible track limits;auto-fitandauto-fillfor responsive repetition;gapfor gutters;- named lines and template areas for readable placement;
subgridwhen a nested grid should share tracks with its parent.
Grid changes visual layout, not document semantics. Keep the source order meaningful for reading and keyboard navigation; avoid using placement solely to create a visual order that contradicts the DOM.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents