Intro to Grid: Free Web Development Tutorial
Master CSS Grid Layout for Modern Web Design
What You'll Learn
Grid Fundamentals
Understand how to create columns, rows, and gaps using CSS Grid. Learn the difference between explicit and implicit grid structures.
Firefox DevTools
Master Firefox's superior grid inspection tools to visualize and debug your grid layouts effectively.
Practical Implementation
Follow along with hands-on exercises using real code examples and see immediate results in your browser.
Grid vs Flexbox: When to Use Which
| Feature | CSS Grid | Flexbox |
|---|---|---|
| Best Use Case | Layout structure in mind | Content needs to fit |
| Approach | Layout first | Content first |
| Dimension Control | Two-dimensional | One-dimensional |
| Planning Required | Structure predetermined | Flexible adaptation |
Use grid when you already have the layout structure in mind, and flex when you just want everything to fit. Layout first vs. content first.
Setup Requirements
Firefox has superior DevTools for inspecting CSS Grid at the time of writing
Locate in Desktop > Class Files > yourname-Flexbox Grid Class
You'll be reloading frequently to see changes as you code
Orange border container div wraps numbered divs with different background colors
Grid Direction Control
| Feature | Row Direction (Default) | Column Direction |
|---|---|---|
| Property Value | grid-auto-flow: row | grid-auto-flow: column |
| Item Flow | Creates new rows | Creates new columns |
| Size Control | grid-auto-rows | grid-auto-columns |
| Use Case | Vertical content flow | Horizontal content flow |
Fractional Units (fr) Explained
1fr = Equal Distribution
When using 1fr 1fr, available space is divided equally between columns after fixed-width columns are calculated.
2fr 1fr = Proportional
The first column gets twice as much free space as the second. Think of it as distributing 3 units total: 2 to first, 1 to second.
repeat() Function
Use repeat(3, 1fr) instead of 1fr 1fr 1fr. Can repeat patterns like repeat(3, 1fr 50px) for alternating column types.
Key Takeaways


