Skip to content
Parwaz DigitalMarketing · Web · Courses

Web Development Course · Module 1, lesson 5

CSS Grid and building your first complete page

Use CSS Grid to build two-dimensional page layouts with rows and columns, then combine Grid, Flexbox and semantic HTML into a finished page.

What you will learn

  • Define grid columns and rows with grid-template-columns and fr units
  • Place items across multiple columns or rows
  • Decide when to use Grid and when to use Flexbox

CSS Grid controls rows and columns at the same time. Setting display: grid on a container and grid-template-columns: 1fr 1fr 1fr creates three equal columns. The fr unit means a fraction of the free space. Add gap to space the cells. The repeat() function shortens this, so repeat(3, 1fr) means the same thing, and children fill the cells in order.

A very useful pattern is grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)). It fits as many columns as possible, each at least 250 pixels wide, and stretches them to fill the row. The grid adjusts as the screen changes without any extra rules. Individual items can span several cells with properties such as grid-column: span 2, which suits a featured product or a wide banner.

Grid and Flexbox work well together. A good rule of thumb is to use Grid for the overall page or a gallery, where rows and columns both matter, and Flexbox for arranging items inside a component, such as a card's title and button. To finish your first page, combine semantic HTML, a consistent colour and type style, Grid for the layout and Flexbox for the details.

Practice task

Turn your bakery page into a complete page: a Flexbox header, a Grid gallery of six products using auto-fit and minmax, an about section and a footer with contact details.

Web Development Course

Learn this properly,with a final project.

These pages summarise each lesson. The full course teaches them hands-on. Message us for the current fee, schedule, and format.

Available for new projects — Replies within one business day