Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Flexbox

The align-self property

Reference for the CSS align-self property: override the container's align-items for one flex or grid item, with values, live examples and usage notes.

The align-self property lets a single item ignore the container's align-items and choose its own alignment on the cross axis. Every other item keeps following the container.

The initial value auto means "do what the container says".

CSS
.row { display: flex; align-items: flex-start; }
.row .badge { align-self: center; }

Try it

One item breaks the rule
Chat bubbles with align-self

Syntax

CSS
align-self: auto | normal | stretch | <baseline-position>
  | [ <overflow-position>? <self-position> ];
  • Initial value: auto
  • Applies to: flex items, grid items and absolutely positioned boxes
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto Use the parent's align-items value.
stretch Fill the line on the cross axis, if the item's size on that axis is auto.
flex-start, flex-end Pin the item to the cross-start or cross-end edge.
start, end, self-start, self-end Writing-mode-aware positions; they also work in grid.
center Center the item on the cross axis.
baseline Align the item's first baseline with the other baseline-aligned items (last baseline for the last line).
safe / unsafe Optional prefix controlling overflow behavior, as for align-items.

Usage notes

  • Cross axis only. There is no justify-self in flexbox: on the main axis use auto margins (margin-left: auto) to push a single item.
  • Grid is different. In grid, align-self places an item in its grid area vertically, and justify-self does the same horizontally.
  • Stretch needs an auto size. A fixed height prevents stretch in a row container.
  • Absolute boxes. On an absolutely positioned element, align-self aligns it within its containing block when both insets are set. Support for this is more recent than for flex items.
  • Baseline groups. Items using baseline align with each other, not with items using another value.
  • Prefer a class. One align-self on a special item is easier to read and maintain than adding wrapper elements.

Browser support

Supported in every browser for flex and grid items. Use on absolutely positioned boxes is only in current browsers.