CSS align-self Property

The align-self property controls the alignment of an individual flexbox or grid item, overriding the default alignment set by its container.

It allows one item to use a different alignment from its siblings. In flexbox, it works along the cross axis of the item's flex line. In grid layout, it aligns the item along the block axis within its grid area.

align-self Syntax

selector {
  align-self: auto;
}

Replace auto with an alignment value such as start, center, end, stretch, or baseline.

The property also accepts the global CSS values inherit, initial, revert, revert-layer, and unset.

Property Values

Value Description
auto Uses the alignment established by the parent container's align-items property. This is the initial value.
normal Uses the normal alignment behavior for the layout mode, typically similar to stretch for flex items and many grid items.
stretch Stretches an eligible item to fill the available space along the alignment axis, subject to its sizing constraints.
start Aligns the item toward the start of the alignment axis.
end Aligns the item toward the end of the alignment axis.
center Centers the item along the alignment axis.
flex-start Aligns a flex item toward the cross-start edge of its flex line.
flex-end Aligns a flex item toward the cross-end edge of its flex line.
self-start Aligns the item toward its own start side along the alignment axis.
self-end Aligns the item toward its own end side along the alignment axis.
baseline Aligns the item using the first baseline alignment group.
first baseline Explicitly requests first-baseline alignment.
last baseline Aligns the item using the last baseline alignment group.
safe center Centers the item unless doing so would cause unsafe overflow, in which case start alignment is used.
unsafe center Centers the item without the overflow protection provided by safe.

The safe and unsafe keywords can also be combined with other supported positional alignment values.

The property is not inherited. Its initial value is auto, which follows the container's align-items setting.

How align-self Works

The align-self property is applied directly to a flex or grid item rather than its container.

By default, an item uses the alignment established by the container's align-items property. Setting align-self to another value overrides that alignment for the selected item.

.container {
  display: flex;
  align-items: center;
}
.special-item {
  align-self: flex-start;
}

In this example, most items follow the container's centered alignment. The item with the special-item class aligns toward the cross-start edge instead.

In flexbox, cross-axis auto margins take precedence over align-self. If an item has an auto margin along that axis, the alignment property may not produce the expected result.

Flexbox Alignment

In flexbox, align-self controls the position of one item along the cross axis of its flex line.

.flex-container {
  display: flex;
  align-items: center;
  height: 180px;
  gap: 10px;
}
.flex-item {
  padding: 12px;
  background-color: #1769aa;
  color: #fff;
}
.flex-item.special {
  align-self: flex-end;
}

Most items are centered vertically in a row-direction flex container. The item with the special class moves toward the bottom of the flex line.

The cross axis changes with flex-direction. For flex-direction: column, align-self generally controls horizontal alignment in a horizontal writing mode.

Grid Alignment

In grid layout, align-self positions an individual grid item along the block axis within its assigned grid area.

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 140px;
  align-items: start;
  gap: 10px;
}
.grid-item {
  padding: 12px;
  background-color: #1769aa;
  color: #fff;
}
.grid-item.special {
  align-self: end;
}

The regular grid items align toward the start of their grid areas. The special item aligns toward the end of its grid area.

Unlike flexbox, grid alignment uses the block axis of the grid area rather than a flex line's cross axis.

align-self Example

The following example uses align-items: center on a flex container, then applies different align-self values to individual items.

<div class="align-self-demo">
  <div class="item start">Start</div>
  <div class="item center">Center</div>
  <div class="item end">End</div>
</div>
.align-self-demo {
  display: flex;
  align-items: center;
  width: 320px;
  max-width: 100%;
  height: 160px;
  gap: 8px;
  padding: 8px;
  border: 1px solid #ccc;
  box-sizing: border-box;
}
.align-self-demo .item {
  flex: 1;
  padding: 10px 4px;
  background-color: #1769aa;
  color: #fff;
  text-align: center;
}
.align-self-demo .start {
  align-self: flex-start;
}
.align-self-demo .center {
  align-self: center;
}
.align-self-demo .end {
  align-self: flex-end;
}

Each item occupies a different vertical position within the same flex container.

Browser Result
Start
Center
End

The first item aligns at the top, the second remains centered, and the third aligns at the bottom. This demonstrates how align-self overrides the container's default alignment for individual items.

align-self vs. align-items

Both properties control item alignment, but they are applied to different elements.

Property Purpose
align-items Sets the default alignment for all items in a flex or grid container.
align-self Overrides that alignment for an individual flex or grid item.

Use align-items when the same alignment should apply to all items. Use align-self when one or more items need a different alignment.

Browser Support

The align-self property is widely supported for flexbox and grid layouts in modern browsers, including Chrome, Edge, Firefox, and Safari. Support for some advanced alignment values may vary.

Visit Can I Use? to check current browser compatibility.

Specifications

The align-self property is defined in the CSS Box Alignment Module Level 3 specification.

CSS Box Alignment Module Level 3