Originally published on CodingCush .
CSS Grid is a layout system built into CSS that lets you place items in rows and columns at the same time. You turn a parent element into a grid container with display: grid , define the columns and rows, add spacing with gap , and the browser lines everything up for you. In this guide you will learn the core ideas step by step, build a complete card gallery you can copy, and see when Grid beats Flexbox.
What Is a Grid Container?
Every grid starts with a container. Pick the element that wraps your items, a div , a section or a main element, and set display: grid on it. That one line changes how its direct children behave. The children become grid items, and the container controls where they sit.
Think of it like a spreadsheet. Columns run down, rows run across, and each item sits in a cell where a row and a column meet. Lines are the borders between cells, and tracks are the rows and columns themselves.…