`place-items` CSS property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It's been available across browsers since September 2015.
The place-items CSS shorthand property aligns items along both block and inline directions at the same time.
Try it
place-items: center stretch;
place-items: center start;
place-items: start end;
place-items: end center;
<section class="default-example" id="default-example">
<div class="example-container">
<div class="transition-all" id="example-element">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>
</div>
</section>
#example-element {
border: 1px solid #c5c5c5;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: 80px;
grid-gap: 10px;
width: 220px;
}
#example-element > div {
background-color: rgb(0 0 255 / 0.2);
border: 3px solid blue;
}
Constituent properties
This property is a shorthand for the following CSS properties:
Syntax
/* Positional alignment */ place-items: center; place-items: normal start; place-items: center normal; place-items: start legacy; place-items: end normal; place-items: self-start legacy; place-items: self-end normal; place-items: flex-start legacy; place-items: flex-end normal; place-items: anchor-center; /* Baseline alignment */ place-items: baseline normal; place-items: first baseline legacy; place-items: last baseline normal; place-items: stretch legacy; /* Global values */ place-items: inherit; place-items: initial; place-items: revert; place-items: revert-layer; place-items: unset;
Values
This property is specified as one or two space-separated values of the following types, in the order listed:
-
align-items - Specifies the alignment in the block direction.
-
justify-itemsOptional - Specifies the alignment in the inline direction. If omitted, the
align-itemsvalue is used.
Description
The place-items shorthand property sets align-items and justify-items in a single declaration, aligning items along both the block and inline directions.
If only one value is provided, the value is used to set alignment in both block and inline directions. If two values are provided, the first value is the align-items value, setting the alignment in the block direction, and the second value is the justify-items value, setting alignment in the inline direction.
Formal definition
| Initial value | as each of the properties of the shorthand: |
|---|---|
| Applies to | all elements |
| Inherited | no |
| Computed value | as each of the properties of the shorthand: |
| Animation type | discrete |
Formal syntax
place-items =
<'align-items'> <'justify-items'>?
Examples
Placing items in a flex container
In flexbox justify-self or justify-items do not apply, as on the main axis items are treated as a group. Therefore, the second value will be ignored.
div > div {
box-sizing: border-box;
border: 2px solid #8c8c8c;
width: 50px;
display: flex;
align-items: center;
justify-content: center;
}
#item1 {
background-color: #8cffa0;
min-height: 30px;
font-size: 2em;
}
#item2 {
background-color: #a0c8ff;
min-height: 50px;
}
#item3 {
background-color: #ffa08c;
min-height: 40px;
}
#item4 {
background-color: #ffff8c;
min-height: 60px;
}
#item5 {
background-color: #ff8cff;
min-height: 70px;
}
#item6 {
background-color: #8cffff;
min-height: 50px;
}
select {
font-size: 16px;
}
.row {
margin-top: 10px;
}
<div id="container">
<div id="item1">1</div>
<div id="item2">2</div>
<div id="item3">3</div>
</div>
<div class="row">
<label for="values">place-items: </label>
<select id="values">
<option value="stretch">stretch</option>
<option value="start">start</option>
<option value="center">center</option>
<option value="end">end</option>
<option value="left">left</option>
<option value="right">right</option>
<option value="auto center">auto center</option>
<option value="normal start">normal start</option>
<option value="center normal">center normal</option>
<option value="start auto">start auto</option>
<option value="end normal">end normal</option>
<option value="self-start auto">self-start auto</option>
<option value="self-end normal">self-end normal</option>
<option value="flex-start auto">flex-start auto</option>
<option value="flex-end normal">flex-end normal</option>
<option value="left auto">left auto</option>
<option value="right normal">right normal</option>
<option value="baseline normal">baseline normal</option>
<option value="first baseline auto">first baseline auto</option>
<option value="last baseline normal">last baseline normal</option>
<option value="stretch auto">stretch auto</option>
</select>
</div>
const values = document.getElementById("values");
const container = document.getElementById("container");
values.addEventListener("change", (evt) => {
container.style.placeItems = evt.target.value;
});
CSS
#container {
height: 200px;
width: 240px;
place-items: stretch; /* You can change this value by selecting another option in the list */
background-color: #8c8c8c;
display: flex;
}
Result
Placing items in a grid container
The following grid container has items which are smaller than the grid areas they are placed in, therefore place-items will move them in the block and inline dimensions.
div > div {
box-sizing: border-box;
border: 2px solid #8c8c8c;
}
#item1 {
background-color: #8cffa0;
min-height: 30px;
font-size: 2em;
}
#item2 {
background-color: #a0c8ff;
min-height: 50px;
}
#item3 {
background-color: #ffa08c;
min-height: 40px;
}
#item4 {
background-color: #ffff8c;
min-height: 60px;
}
#item5 {
background-color: #ff8cff;
min-height: 70px;
}
#item6 {
background-color: #8cffff;
min-height: 50px;
}
select {
font-size: 16px;
}
.row {
margin-top: 10px;
}
<div id="grid-container">
<div id="item1">1</div>
<div id="item2">2</div>
<div id="item3">3</div>
<div id="item4">4</div>
<div id="item5">5</div>
</div>
<div class="row">
<label for="grid-values">place-items: </label>
<select id="grid-values">
<option value="stretch">stretch</option>
<option value="start">start</option>
<option value="center">center</option>
<option value="end">end</option>
<option value="left">left</option>
<option value="right">right</option>
<option value="auto center">auto center</option>
<option value="normal start">normal start</option>
<option value="center normal">center normal</option>
<option value="start auto">start auto</option>
<option value="end normal">end normal</option>
<option value="self-start auto">self-start auto</option>
<option value="self-end normal">self-end normal</option>
<option value="flex-start auto">flex-start auto</option>
<option value="flex-end normal">flex-end normal</option>
<option value="left auto">left auto</option>
<option value="right normal">right normal</option>
<option value="baseline normal">baseline normal</option>
<option value="first baseline auto">first baseline auto</option>
<option value="last baseline normal">last baseline normal</option>
<option value="stretch auto">stretch auto</option>
</select>
</div>
const values = document.getElementById("grid-values");
const container = document.getElementById("grid-container");
values.addEventListener("change", (evt) => {
container.style.placeItems = evt.target.value;
});
CSS
#grid-container {
height: 200px;
width: 240px;
place-items: stretch; /* You can change this value by selecting another option in the list */
background-color: #8c8c8c;
display: grid;
grid-template-columns: repeat(3, 1fr);
}
#grid-container > div {
width: 50px;
}
Result
Specifications
| Specification |
|---|
| CSS Box Alignment Module Level 3 # place-items-property |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | WebView on iOS | |
place-items |
59 |
79 |
45 |
46 |
11 |
59 |
45 |
43 |
11 |
7.0 |
59 |
11 |
anchor-center |
125 |
125 |
147 |
111 |
26 |
125 |
147 |
83 |
26 |
27.0 |
125 |
26 |
flex_context |
59 |
79 |
45 |
46 |
11 |
59 |
45 |
43 |
11 |
7.0 |
59 |
11 |
grid_context |
59 |
79 |
45 |
46 |
11 |
59 |
45 |
43 |
11 |
7.0 |
59 |
11 |
See also
align-itemsalign-selfjustify-itemsjustify-self- Basic concepts of flexbox
- Aligning items in a flex container
- Box alignment in grid layout
- CSS box alignment module
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/place-items