CHAPTER 71

CSS Grid Introduction

Learn the fundamentals of CSS Grid for two-dimensional layouts.

01. What is CSS Grid Introduction?

CSS Grid is a two-dimensional layout system.
It controls rows and columns simultaneously.
Grid is useful for complex page and card layouts.

02. Syntax

.container { display: grid; }

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>

.grid {
    display: grid;
    grid-template-columns:
        repeat(3, 1fr);
    gap: 20px;
}

.card {
    padding: 30px;
    background: #dbeafe;
}

</style>
</head>
<body>

<div class="grid">

    <div class="card">One</div>
    <div class="card">Two</div>
    <div class="card">Three</div>

</div>

</body>
</html>

04. Important Points

✓ display: grid creates a grid container.
✓ grid-template-columns defines columns.
✓ gap creates spacing.
✓ fr represents a fraction of available space.

05. Common Mistakes

⚠ Creating too many fixed columns.
⚠ Ignoring mobile layouts.
⚠ Confusing Grid with Flexbox.

06. Real World Use

CSS Grid is useful for galleries, dashboards, course cards and complete website layouts.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Create a Three-Column Grid

Create six cards in a three-column CSS Grid.