align-self
Specifies the cross-axis alignment for individual flex items. Can override the container's 'align-items' value.
Sample Code
style.css
/* Follow the container's align-items (default) */
.item { align-self: auto;}
/* Center this item only */
.item-center { align-self: center;}
/* Align this item to the bottom only */
.item-end { align-self: flex-end;}
/* Stretch this item only */
.item-stretch { align-self: stretch;}
Available Values
| Value | Description |
|---|---|
| auto | Uses the container's 'align-items' value. This is the initial value. |
| flex-start | Aligns the item to the start of the cross axis. |
| flex-end | Aligns the item to the end of the cross axis. |
| center | Centers the item along the cross axis. |
| baseline | Aligns the item to the text baseline within the item. |
| stretch | Stretches the item to fill the cross axis. |
Specification
| Property | Details |
|---|---|
| Initial Value | auto |
| Applies to | Flex items |
| Inherited | No |
| Animation | Not animatable (discrete) |
Browser Support
28 △
27 △
26 △
25 △
24 △
23 △
22 △
21 △
20 and earlier ×
19 and earlier ×
7 △
6 and earlier ×
8 ×
7 ×
6 ×
11 and earlier ×
7 △
6 and earlier ×
Android Browser
4.4 + ○
3 and earlier ×Description
'align-self' is a property specified on individual flex items that lets you override the container's 'align-items' value for that item alone. Use it when you want something like "align everything to the top, but center just this one item".
Relationship with align-items
'align-items' is a property specified on the container that sets the alignment for all items at once. 'align-self' is a property specified on individual items to override that setting. When 'align-self: auto' (the initial value) is set, the container's 'align-items' value is applied as-is.
.container {
display: flex;
align-items: flex-start; /* All items align to top */
height: 200px;
}
.item-a { /* align-self: auto -> flex-start is applied */ }
.item-b { align-self: center;} /* Only this item is centered */
.item-c { align-self: flex-end;} /* Only this item aligns to bottom */
Pattern: Pin Footer to Bottom
/* Pin only the footer to the bottom within a card */
.card {
display: flex;
flex-direction: column;
height: 300px;
}
.card-body { flex: 1;}
.card-footer {
align-self: flex-end; /* Place at the end of the cross axis (horizontal) */
}
Related Properties
| Property | Description |
|---|---|
| align-items | Sets the cross-axis alignment for all items in the container at once. 'align-self' overrides this value on a per-item basis. |
| justify-content | Controls alignment along the main axis. There is no standard property to override the main-axis alignment for individual items ('margin: auto' can be used as a workaround). |
If you find any errors or copyright issues, please contact us.