Introduction to CSS Grid
CSS Grid is a powerful two-dimensional layout system for creating complex layouts.
What is CSS Grid?
Grid allows you to:
- Create rows AND columns simultaneously
- Place items precisely in cells
- Build complex layouts with simple CSS
- Create responsive designs easily
Creating a Grid Container
Add display: grid to create a grid:
Loading CSS Playground...
Interactive Grid Playground
Loading Grid Playground...
Grid vs Flexbox
Loading CSS Playground...
Grid Terminology
Loading CSS Playground...
- Track: A row or column
- Cell: The space between grid lines
- Gap: Space between cells
- Line: The dividing lines (numbered from 1)
The fr Unit
fr means "fraction of available space":
Loading CSS Playground...
The middle column gets 2 parts, sides get 1 part each.
Practical: Photo Gallery
Loading CSS Playground...
Exercise: Create a Grid
Add display: grid and create 3 columns:
Loading CSS Exercise...
Up next · Lesson 21 of 27
Grid Template Columns and Rows
2 min read
20 of 27 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

