CSS <self-position> Data Type
The <self-position> data type is a keyword that places a single item in its space: center, start, end, self-start, self-end, flex-start or flex-end.
Description
The <self-position> CSS data type represents the keywords that position a single item inside the space available to it, its alignment area, such as a grid cell or the cross axis of a flex line. It is used by align-self, justify-self and place-self on individual items, and by align-items, justify-items and place-items on the container to set a default for all items.
The keywords are center, start, end, self-start, self-end, flex-start and flex-end. start and end use the writing mode of the container, while self-start and self-end use the item's own writing mode, which only matters when they differ. flex-start and flex-end follow the flex direction and only make a difference in flex layout. The anchor-center keyword can also be used on anchor-positioned elements to centre them on their anchor.
A <self-position> can be preceded by safe or unsafe (see <overflow-position>). Other alignment values such as stretch, normal and the <baseline-position> keywords are accepted by the same properties but are not part of this type.
Examples:
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
place-items: center; /* every item centred in its cell */
}
.grid .badge {
justify-self: end; /* this item moves to the end */
align-self: start;
}
Interactive Demo
Syntax
<self-position> = center | start | end | self-start | self-end | flex-start | flex-end
Values
- centerThe item is centred in its alignment area.
- startThe item is aligned to the start edge of the alignment area, in the container's writing mode.
- endThe item is aligned to the end edge of the alignment area, in the container's writing mode.
- self-startThe item is aligned to the edge that is the start in its own writing mode.
- self-endThe item is aligned to the edge that is the end in its own writing mode.
- flex-startIn flex layout, aligns the item to the cross-start side of the flex line. Elsewhere it behaves like start.
- flex-endIn flex layout, aligns the item to the cross-end side of the flex line. Elsewhere it behaves like end.
Example
Browser Support
The following information will show you the current browser support for the CSS self-position data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
Desktop





Tablets & Mobile





