Comprehensive guide to modern HTML and CSS development.
While Flexbox is for one-dimensional layouts (a row OR a column), CSS Grid is for two-dimensional layouts (Rows AND Columns simultaneously).
display: grid; applied to the parent container.grid-template-columns and grid-template-rows define the grid tracks. You can use pixels, percentages, or the powerful fr (fractional) unit.gap adds spacing between the grid items.Example: grid-template-columns: 1fr 2fr 1fr; creates three columns where the middle one is twice as wide as the outer ones.
Edit the code below and click Run to see the result live.