CSS place-items Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Grid & Flexbox

What You’ll Learn

The place-items property is a shorthand for align-items and justify-items. It aligns each item inside its own grid cell or flex area.

01

Shorthand

Two in one.

02

Grid Cells

Per-item align.

03

center

Common value.

04

stretch

Default-like.

05

Two Values

Block + inline.

06

Flexbox

Also supported.

Introduction

The place-items property in CSS is a shorthand for setting both the align-items and justify-items properties in a grid or flex container.

This property simplifies the alignment of grid items or flex items within their container, allowing for cleaner and more concise code. It helps control the positioning of items both horizontally and vertically inside their areas.

Definition and Usage

Use place-items when every child should follow the same alignment rule inside its cell. This is different from place-content, which moves the entire track group inside the container.

A single value such as center is one of the most common patterns for icon buttons, cards, and centered content blocks in grid layouts.

💡
Beginner Tip

If one small box should sit in the middle of a grid cell, use place-items: center on the container instead of margins on the child.

📝 Syntax

The syntax for the place-items property is as follows:

syntax.css
element {
  place-items: align-items justify-items;
}

Here, align-items and justify-items control alignment along the block and inline axes. You can set both values at once with this shorthand.

Basic Example

place-items.css
.container {
  display: grid;
  place-items: center;
}

Syntax Rules

  • One value sets both align-items and justify-items.
  • Two values set block axis first, then inline axis.
  • Works on grid containers and flex containers.
  • Best for aligning items inside cells, not moving whole track groups.
  • Common values include start, center, end, and stretch.
  • Use place-self when only one child needs a different alignment.

🎯 Default Value

The initial value of place-items follows align-items and justify-items. In grid layouts, this typically behaves like stretch on both axes, so items expand to fill their cells unless you set another value.

⚡ Quick Reference

QuestionAnswer
Shorthand foralign-items + justify-items
Applies toGrid and flex containers
InheritedNo
AnimatableNo
Common useCenter or align all items inside their cells

💎 Property Values

place-items accepts the same values as align-items and justify-items.

align-items values (block axis)

  • start — Align items to the start of the block axis.
  • center — Align items to the center of the block axis.
  • end — Align items to the end of the block axis.
  • stretch — Stretch items to fill the container along the block axis.

justify-items values (inline axis)

  • start — Align items to the start of the inline axis.
  • center — Align items to the center of the inline axis.
  • end — Align items to the end of the inline axis.
  • stretch — Stretch items to fill the container along the inline axis.
ValueExampleDescription
centerplace-items: center;Centers every item inside its cell on both axes.
stretchplace-items: stretch;Stretches items to fill available cell space where supported.
two valuesplace-items: start end;Sets block-axis alignment first, then inline-axis alignment.
center stretch start end start end

When Does place-items Matter?

place-items is ideal when each child should align consistently inside its own area:

  • Centered icons — Put icons or avatars in the middle of square grid cells.
  • Dashboard tiles — Align card content uniformly across a grid.
  • Form controls — Center labels or buttons inside fixed-size cells.
  • Less CSS noise — Replace two longhand properties with one declaration.

If the whole grid should move inside a larger container, use place-content instead.

👀 Live Preview

Compare place-items: stretch with place-items: center inside the same-sized cell.

stretch

center

Examples Gallery

Start with a centered grid item, align multiple cells, try two-value syntax, and use flexbox.

▦ Grid Item Alignment

Use place-items on grid containers — matching the reference example.

Example 1 — Centered Grid Item

In this example, we’ll use the place-items property to center items both horizontally and vertically within a grid container.

place-items-center.html
<style>
  .container {
    display: grid;
    height: 200px;
    width: 200px;
    place-items: center;
    border: 1px solid #000;
  }

  .item {
    width: 50px;
    height: 50px;
    background-color: lightblue;
  }
</style>

<div class="container">
  <div class="item"></div>
</div>
Try It Yourself

How It Works

The grid container centers the item both horizontally and vertically within its bounds using one shorthand declaration.

Example 2 — Center Every Cell

With multiple grid items, place-items: center applies the same alignment rule inside every cell.

place-items-grid.html
<style>
  .container {
    display: grid;
    grid-template-columns: repeat(2, 6rem);
    place-items: center;
  }
</style>
Try It Yourself

How It Works

Each item is centered inside its own track area, even when cells are larger than the item content.

🔀 Mixed Axes & Flexbox

Use two-value syntax or apply place-items in flex layouts.

Example 3 — Two Values

Use place-items: start end to align items to the top and right inside each cell.

place-items-two-values.html
<style>
  .container {
    display: grid;
    place-items: start end;
  }
</style>
Try It Yourself

How It Works

The first value controls block-axis alignment (start). The second controls inline-axis alignment (end).

Example 4 — Flex Container

Apply place-items: center on a flex container to align flex items along both axes.

place-items-flex.html
<style>
  .container {
    display: flex;
    place-items: center;
    height: 8rem;
  }
</style>
Try It Yourself

How It Works

Although grid is the most common use case, place-items also works on flex containers for consistent item alignment.

place-items vs align-items and justify-items

place-items is shorthand for align-items (block axis) and justify-items (inline axis).

It is different from place-content, which aligns the entire content group rather than each item inside its cell.

shorthand-vs-longhand.css
/* Shorthand */
.container {
  place-items: center;
}

/* Longhand equivalent */
.container {
  align-items: center;
  justify-items: center;
}

🧠 How place-items Works

1

Container creates cells or lines

Grid or flex layout divides space into areas for child items.

display: grid
2

You set place-items

One or two keywords define alignment inside every cell.

CSS rule
3

Each item is positioned in its area

Items move within their own track space according to the chosen alignment.

Layout engine
=

Consistent item alignment

Every child follows the same centering or stretching rule with minimal CSS.

Browser Compatibility

The place-items property is supported in most modern browsers. It is generally compatible with the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, older browser versions may not fully support this property, so testing across different browsers is recommended to ensure consistent behavior.

Grid & Flex · Modern support

Reliable place-items support

Chrome, Firefox, Safari, Edge, and Opera support place-items for grid and flex layouts.

96% Modern browser support
Google Chrome 59+ · Desktop & Mobile
Full support
Mozilla Firefox 45+ · Desktop & Mobile
Full support
Apple Safari 11+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 46+ · Modern versions
Full support

Testing tip

Test grid and flex examples separately in your target browsers, especially when using two-value syntax.

place-items property 96% supported

Bottom line: place-items is widely available in modern browsers and is safe for grid-centered UI patterns.

Conclusion

The place-items property is a convenient shorthand for aligning grid or flex items along both the block and inline axes.

By using this property, you can simplify your CSS and achieve precise alignment with minimal code. Experiment with different values to see how they affect the layout and alignment of your items, and incorporate this property to enhance the design and functionality of your web projects.

💡 Best Practices

✅ Do

  • Use place-items: center for quick cell centering in grids
  • Prefer shorthand when both axes share the same alignment
  • Give grid cells enough size to see alignment effects clearly
  • Use place-self for one-off item overrides
  • Pair with explicit grid-template-columns for dashboards

❌ Don’t

  • Confuse place-items with place-content
  • Expect place-items to move the whole grid inside a parent
  • Rely on stretch when items should keep intrinsic size
  • Forget that flex and grid may interpret axes differently
  • Override every item manually when one container rule is enough

Key Takeaways

Knowledge Unlocked

Five things to remember about place-items

Use these points when aligning items inside grid and flex areas.

5
Core concepts
02

stretch Default

Typical grid behavior.

Default
03

center

Most common value.

Pattern
04

Per Cell

Not whole tracks.

Scope
pc 05

place-content

Different shorthand.

Related

❓ Frequently Asked Questions

place-items is a shorthand that sets align-items and justify-items together. It controls how each item is aligned inside its grid cell or flex line.
place-items aligns individual items inside their cells. place-content aligns the whole group of tracks or lines within the container.
Yes. place-items works on flex containers and grid containers. On flex, it mainly affects align-items and justify-items behavior for items.
A single value applies to both align-items and justify-items. For example, place-items: center centers every item in its cell on both axes.
The initial value follows align-items and justify-items. In grid layouts this typically behaves like stretch on both axes unless you set something else.

Practice in the Live Editor

Open the HTML editor, build a grid, and experiment with place-items on the container.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful