This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
* Some parts of this feature may have varying levels of support.
The place-self CSS shorthand property allows you to align an individual item in both the block and inline directions at once (i.e., the align-self and justify-self properties). This property applies to block-level boxes, absolutely-positioned boxes, and grid items. If the second value is not present, the first value is also used for it.
place-self: stretch center;
place-self: center start;
place-self: start end;
place-self: end center;
<section class="default-example" id="default-example">
<div class="example-container">
<div class="transition-all" id="example-element">One</div>
<div>Two</div>
<div>Three</div>
</div>
</section>
.example-container {
border: 1px solid #c5c5c5;
display: grid;
width: 220px;
grid-template-columns: 1fr 1fr;
grid-auto-rows: 80px;
grid-gap: 10px;
}
.example-container > div {
background-color: rgb(0 0 255 / 0.2);
border: 3px solid blue;
}
This property is a shorthand for the following CSS properties:
/* Positional alignment */ place-self: auto center; place-self: normal start; place-self: center normal; place-self: start auto; place-self: end normal; place-self: self-start auto; place-self: self-end normal; place-self: flex-start auto; place-self: flex-end normal; place-self: anchor-center; /* Baseline alignment */ place-self: baseline normal; place-self: first baseline auto; place-self: last baseline normal; place-self: stretch auto; /* Global values */ place-self: inherit; place-self: initial; place-self: revert; place-self: revert-layer; place-self: unset;
autoComputes to the parent's align-items value.
normalThe effect of this keyword is dependent of the layout mode we are in:
start on replaced absolutely-positioned boxes, and as stretch on all other absolutely-positioned boxes.stretch.stretch.stretch, except for boxes with an aspect ratio or an intrinsic size where it behaves like start.self-startAligns the items to be flush with the edge of the alignment container corresponding to the item's start side in the cross axis.
self-endAligns the items to be flush with the edge of the alignment container corresponding to the item's end side in the cross axis.
flex-startThe cross-start margin edge of the flex item is flushed with the cross-start edge of the line.
flex-endThe cross-end margin edge of the flex item is flushed with the cross-end edge of the line.
centerThe flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.
baseline, first baseline. last baselineSpecifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box's first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group. The fallback alignment for first baseline is start, the one for last baseline is end.
stretchIf the combined size of the items along the cross axis is less than the size of the alignment container and the item is auto-sized, its size is increased equally (not proportionally), while still respecting the constraints imposed by max-height/max-width (or equivalent functionality), so that the combined size of all auto-sized items exactly fills the alignment container along the cross axis.
anchor-centerIn the case of anchor-positioned elements, aligns the item to the center of the associated anchor element in the block and inline direction. See Centering on the anchor using anchor-center.
| Initial value | as each of the properties of the shorthand:
|
|---|---|
| Applies to | block-level boxes, absolutely-positioned boxes, and grid items |
| Inherited | no |
| Computed value | as each of the properties of the shorthand:
|
| Animation type | discrete |
place-self =
<'align-self'> <'justify-self'>?
<align-self> =
auto |
normal |
stretch |
<baseline-position> |
<overflow-position>? <self-position> |
anchor-center
<justify-self> =
auto |
normal |
stretch |
<baseline-position> |
<overflow-position>? [ <self-position> | left | right ] |
anchor-center
<baseline-position> =
[ first | last ]? &&
baseline
<overflow-position> =
unsafe |
safe
<self-position> =
center |
start |
end |
self-start |
self-end |
flex-start |
flex-end
In the following example we have a 2 x 2 grid layout. Initially the grid container has justify-items and align-items values of stretch — the defaults — which causes the grid items to stretch across the entire width of their cells.
The second, third, and fourth grid items are then given different values of place-self, to show how these override the default placements. These values cause the grid items to span only as wide/tall as their content width/height, and align in different positions across their cells, in the block and inline directions.
<article class="container"> <span>First</span> <span>Second</span> <span>Third</span> <span>Fourth</span> </article>
html {
font-family: helvetica, arial, sans-serif;
letter-spacing: 1px;
}
article {
background-color: red;
display: grid;
grid-template-columns: 1fr 1fr;
grid-auto-rows: 80px;
grid-gap: 10px;
margin: 20px;
width: 300px;
}
span:nth-child(2) {
place-self: start center;
}
span:nth-child(3) {
place-self: center start;
}
span:nth-child(4) {
place-self: end;
}
article span {
background-color: black;
color: white;
margin: 1px;
text-align: center;
}
article,
span {
padding: 10px;
border-radius: 7px;
}
| Specification |
|---|
| CSS Box Alignment Module Level 3> # place-self-property> |
| 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-self |
59 | 79 | 45 | 46 | 11 | 59 | 45 | 43 | 11 | 7.0 | 59 | 11 |
anchor-center |
125 | 125 | No | 111 | 26 | 125 | No | 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 |
position_absolute_context |
122 | 122 | 134 | 108 | No | 122 | 134 | 81 | No | 26.0 | 122 | No |
© 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/place-self