SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Welcome to CSS
Grid FundamentalsGrid TracksGrid Placement and Layout DecisionsImplicit GridsFlexible GridsGrid AlignmentGrid or Flexbox Placing items on a grid
CSS Grid

Grid Fundamentals

Identify grid items, tracks, cells, and lines, and predict how items fill a simple grid.

In a wrapped flex layout, each line distributes its own space. A collection of cards sometimes needs the second card in every row to begin at the same horizontal position. Grid gives the entire collection a shared set of rows and columns.

Locate the tracks

The element with display: grid becomes the grid container. Its in-flow child elements become grid items. A heading inside one card belongs to the card’s internal layout. The card itself occupies a place in the collection.

A track is the space between two adjacent grid lines. It can be a column or a row. A cell is where one column and one row intersect. An item can occupy one cell or extend across several cells.

Follow a horizontal, left-to-right grid with three columns and two rows. It has six cells and four column lines. The left edge is line 1, the right edge is line 4, and the two interior boundaries are lines 2 and 3. A gap adds space between tracks without creating another track for an item.

Four numbered column lines enclose three column tracks. Both rows use the same boundaries: A aligns with D, B with E, and C with F.

Predict the next item’s position

If the grid has three columns and the items have no assigned positions or spans, the usual row-wise placement fills the first row in source order. The fourth item begins the second row under the first item. Longer text in one card can increase the height of its row while the column boundaries still line up across rows.

Key Takeaways

  • Grid items share the container’s row and column tracks.
  • Count lines to locate track boundaries. Count cells to predict where the next item fits.

Try it yourself

Try it yourself

Arrange four tiles

HTML + CSS

Loading code editor…

Live preview

Updating…

Final output

No comparison yetChecks after 3s without edits
Loading your draft…

How is this lesson?

Previous lesson Sizing and aligning a flex layoutNext lessonGrid Tracks
Edit on GitHubReport on GitHub
On this page
%

On this page

Locate the tracksPredict the next item’s positionKey TakeawaysTry it yourself