CSS Grid - Mastering the Terminology

2023-10-10
By: O. Wolfson

Introduction

As we journey deeper into the world of CSS Grid, understanding its language is pivotal. Like any other system, CSS Grid comes with its own set of terminologies. Familiarizing yourself with these terms will not only simplify the learning curve but also empower you to communicate more effectively about Grid. In this post, we'll dive into the essential vocabulary of CSS Grid.


1. Grid Container

The starting point of any CSS Grid layout is the Grid Container. By setting an element's display property to grid or inline-grid, you transform it into a grid container, making it the mother ship for all grid items.

css
.container {
  display: grid;
}

2. Grid Item

Children (direct descendants) of the grid container are known as grid items. By default, every direct child of your grid container automatically becomes a grid item.

html
<div class="container">
  <div>These</div>
  <div>are</div>
  <div>grid</div>
  <div>items.</div>
</div>

3. Grid Line

Imagine a grid on a piece of paper; the lines that define the structure are the grid lines. In CSS Grid, these lines are the vertical and horizontal lines that divide the grid into sections. They're referenced by numerical values, starting at 1.


4. Grid Track

The space between two adjacent grid lines, either horizontally (row track) or vertically (column track), is known as a grid track.


5. Grid Cell

If you recall tables from basic HTML, a cell is the space between 2 rows and 2 columns. Similarly, in CSS Grid, a cell is the singular space defined by the intersection of one grid row and one grid column.


6. Grid Area

Perhaps one of the most potent aspects of CSS Grid, a grid area, is any space within the grid defined by four grid lines. It can encompass multiple grid cells, allowing you to group various grid items or content pieces.


Wrapping Up: Visualizing The Terminology

Visual aids often help. Here's a simple representation:

-----------------------
|       |       |       |
|   1   |   2   |   3   |
|       |       |       |
-----------------------
|       |       |       |
|   4   |   5   |   6   |
|       |       |       |
-----------------------
  • The entire structure is our Grid Container.
  • Each box (like 1, 2, 3, etc.) is a Grid Item.
  • The lines that form the boxes are Grid Lines.
  • The rows are horizontal Grid Tracks, and the columns are vertical Grid Tracks.
  • Each box can also be termed as a Grid Cell.
  • And a Grid Area can be a group, say boxes 2, 3, 5, and 6 together.

Conclusion

Having a solid grasp of these terminologies will serve as a strong foundation as we delve into more intricate aspects of CSS Grid. The beauty of Grid is its simplicity and power combined, and these terms, once mastered, will feel intuitive.

Coming Next: Now that we're armed with the basic terms, our next post will guide you through setting up your very first grid container and the wonders of rows and columns. Stay tuned!


This post ensures readers are well-versed in the foundational concepts and terms associated with CSS Grid, paving the way for more complex topics in subsequent articles.