Design glossaryA grid layout arranges a page's content in rows and columns that line up. On the web, CSS Grid builds these layouts.
A grid layout places content on an invisible framework of columns and rows, so headings, images, and text blocks line up with each other across the page. The idea comes from print, where Swiss and modernist designers used strict grids to organize newspapers, posters, and books. On the web, the same idea gives pages a consistent structure, and CSS now has a layout system built for it.
Parts of a grid
- Columns: the vertical tracks content sits in. Twelve columns are popular because twelve divides evenly into halves, thirds, quarters, and sixths.
- Gutters: the fixed gaps between columns and rows.
- Margins: the space between the grid and the edge of the screen.
- Rows and modules: horizontal divisions and the cells they create, useful for card layouts and galleries.
Why designers use grids
A grid makes alignment automatic, which is most of what makes a page look tidy. It sets up visual hierarchy, since something spanning eight columns clearly outranks something spanning four. It keeps pages consistent across a whole site, and it gives designers and developers a shared language. The risk is rigidity: a grid followed with no exceptions can look boxy, so most good layouts break it deliberately for a hero image or a pull quote.
CSS Grid
CSS Grid Layout is a two-dimensional layout system supported by all modern browsers. A container with display: grid defines columns and rows, and its children are placed into them:
grid-template-columns: repeat(12, minmax(0, 1fr))creates twelve equal columns.gapsets the gutters.grid-template-areasnames regions such as header, sidebar, and main, which makes complex page layouts readable.repeat(auto-fill, minmax(16rem, 1fr))fits as many cards per row as the screen allows, with no media queries.
Flexbox is the better tool for one-dimensional rows, such as a navigation bar or a row of buttons. Grid is for layouts where rows and columns both matter. One practical tip: a bare 1fr track will not shrink below the minimum width of its content, so a long URL or a wide table can push the page past the screen edge. Using minmax(0, 1fr) instead lets the column shrink.
Grids in WordPress
The block editor's Columns block covers simple side-by-side layouts, and the Group block has a Grid variation that arranges its contents in an automatic or fixed number of columns. Query Loop and Gallery blocks can show posts and images in a grid too. Page builders have their own grid controls, but for most sites the core blocks, with a theme that sets sensible gaps, are enough.
Source: MDN, CSS grid layout.