CSS Reference ยท Flexbox
The place-self property
Reference for the CSS place-self shorthand: set align-self and justify-self together to position a single grid item inside its cell, with live examples.
The place-self property is a shorthand for align-self and justify-self. It positions one item inside its grid area on both axes with a single declaration, overriding the container's place-items.
One value applies to both axes. With two values, the first is the block-axis value (align-self) and the second the inline-axis value (justify-self).
.pin { place-self: end; } .corner { place-self: start end; }
Try it
Items with center, start end and end start shrink to their content and move inside their cells. The stretch item fills its whole cell, which is also what an unstyled grid item does.
Syntax
place-self: <'align-self'> <'justify-self'>?
- Initial value:
auto - Applies to: grid items, plus block-level and absolutely positioned boxes (where the longhands apply)
- Inherited: no
- Animatable: no
- Computed value: as specified for the longhands
Values
| Value | Description |
|---|---|
auto |
Uses the container's align-items / justify-items value. |
stretch |
Fills the area on that axis unless a size is set. |
start, end |
Pins the item to a start or end edge. |
center |
Centers the item. |
self-start, self-end |
Aligns by the item's own writing mode. |
baseline |
Aligns baselines with other baseline-aligned items. |
safe / unsafe |
Optional keyword before a position to control overflow. |
Usage notes
- Flex items. In flexbox only the
align-selfhalf has an effect;justify-selfis ignored there. Use auto margins to push a flex item along the main axis. - Absolute positioning. With
position: absoluteinside a grid area, the values align the box within its containing area whentop,right,bottomandleftare left asauto. - Size matters. Non-stretch values make the item only as big as its content, so add
widthorheightif you need a fixed size. - Order of values. Remember the order: block axis first (vertical in English), then inline axis (horizontal).
start endmeans top right.
Browser support
Supported in all current browsers for grid items.
Related
align-selfโ block-axis longhandjustify-selfโ inline-axis longhandplace-itemsโ the container-level version- Lesson: Grid Alignment