CSS: CSS Grid Items

🗓 Last updated: 2026-11-30👤 Written by: Blake✓ Reviewed by: MOTO🏷 Category: CSS Tutorial

Grid item properties let you precisely control how individual children are placed within a grid container.

Properties in this section: grid-column grid-row grid-area justify-self align-self place-self justify-items align-items grid-template-areas

1. Grid Item Properties

(1) Quick Reference

Property Values Purpose
grid-column 1 / 3, span 2 Column placement
grid-row 1 / 3, span 2 Row placement
grid-area header, 1 / 2 / 3 / 4 Named area or line placement
justify-self start, end, center, stretch Horizontal alignment within cell
align-self start, end, center, stretch Vertical alignment within cell
place-self center, start end Shorthand for justify + align

2. grid-column and grid-row

Control where items start and end on the grid:

▶ Example

▶ Try it Yourself

(1) Full-Width Item

Use grid-column: 1 / -1 to span all columns:

▶ Example

▶ Try it Yourself

3. justify-self / align-self

Control alignment within individual cells:

▶ Example

▶ Try it Yourself

4. Grid Overlap

Grid items can overlap — later items appear on top:

▶ Example

▶ Try it Yourself

Properties in this section: grid-column grid-row grid-area justify-self align-self place-self justify-items align-items grid-template-areas

❓ FAQ

Q How do grid-column and grid-row work? How are grid lines numbered?
A Grid lines start at 1 — a 3-column grid has 4 column lines. grid-column: 1 / 3 places an item from line 1 to line 3 (spanning 2 columns), grid-row: 1 / 2 takes one row. The value before the slash is the start line, after it the end line; you're counting lines, not cells — the classic beginner slip.
Q How do I make a grid item span multiple rows or columns?
A span is the intuitive way: grid-column: span 2; grid-row: span 3; covers 2 columns and 3 rows without naming a start point — the browser finds room. For precise control, grid-column: 1 / 3; grid-row: 1 / 3; gives you a 2×2 block from line 1.
Q What does grid-column: 1 / -1 mean?
A From grid line 1 to the last grid line (-1 is the last line's number) — the full row. Great for full-width headers or divider rows, and it keeps working when you add columns later.
Q How do I use grid-template-areas?
A Draw a map on the container, then let items claim land: grid-template-areas: "header header" "sidebar main" "footer footer"; — each string is one row, repeated names merge into one area. An item just declares header { grid-area: header; }. Far more readable than line numbers, the first choice for page layouts; each row string must list as many areas as there are columns.
Q Can Grid items overlap?
A Yes. Two items assigned the same grid area stack up, the later one on top, with z-index controlling the order. Text over an image, badges over a card — same trick.
Q What's the order of the 4 values in the grid-area shorthand?
A row-start / column-start / row-end / column-end: grid-area: 1 / 1 / 3 / 3 runs from row 1, column 1 to row 3, column 3 (a 2×2 block). Row then column, start then end — chant "row column row column" until it sticks.
Q How do I align a grid item inside its cell? justify-self vs align-self?
A justify-self is horizontal, align-self vertical; values are stretch (default, fills the cell) / start / end / center. To center an image horizontally only: justify-self: center;. The -self versions affect one item without touching siblings.
Q What's the difference between justify-items and justify-content?
A -items sets how each item sits inside its own cell; -content moves the whole grid inside the container — the difference only shows when the grid is smaller than the container. Item looks misaligned? First decide the layer: inside-cell alignment uses -items/-self, whole-grid offsets use -content.
Q Can I change the order of grid items? How does the order property work?
A Yes. Items follow DOM order by default; order: -1 promotes one to the front, lower numbers come first. Handy for promoting a featured card — but don't overuse it: screen readers and Tab focus still follow the DOM, so a big visual/DOM mismatch hurts accessibility.

📖 Summary

📝 Exercises

  1. Create a 4×4 grid, place an item spanning 2 columns and 2 rows starting from column 2, row 2.
  2. Use grid-template-areas for a complete page layout: header (spanning 2 columns), sidebar, content area, footer (spanning 2 columns).
  3. Center all items horizontally and vertically in a grid container (using place-items: center).
  4. Make the third grid item align to the bottom-right corner of its cell (using justify-self and align-self).
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏