W3cubDocs

/CSS

align-self

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨September 2015⁩.

* Some parts of this feature may have varying levels of support.

The align-self CSS property overrides a grid or flex item's align-items value. In grid, it aligns the item inside the grid area. In flexbox, it aligns the item on the cross axis.

Try it

align-self: stretch;
align-self: center;
align-self: start;
align-self: end;
<section class="default-example" id="default-example">
  <div class="example-container">
    <div class="transition-all" id="example-element">One</div>
    <div>Two</div>
    <div>Three</div>
  </div>
</section>
.example-container {
  border: 1px solid #c5c5c5;
  display: grid;
  width: 200px;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 80px;
  grid-gap: 10px;
}

.example-container > div {
  background-color: rgb(0 0 255 / 0.2);
  border: 3px solid blue;
}

The property doesn't apply to block-level boxes, or to table cells. If a flexbox item's cross-axis margin is auto, then align-self is ignored.

Syntax

/* Keyword values */
align-self: auto;
align-self: normal;

/* Positional alignment */
/* align-self does not take left and right values */
align-self: center; /* Put the item around the center */
align-self: start; /* Put the item at the start */
align-self: end; /* Put the item at the end */
align-self: self-start; /* Align the item flush at the start */
align-self: self-end; /* Align the item flush at the end */
align-self: flex-start; /* Put the flex item at the start */
align-self: flex-end; /* Put the flex item at the end */
align-self: anchor-center;

/* Baseline alignment */
align-self: baseline;
align-self: first baseline;
align-self: last baseline;
align-self: stretch; /* Stretch 'auto'-sized items to fit the container */

/* Overflow alignment */
align-self: safe center;
align-self: unsafe center;

/* Global values */
align-self: inherit;
align-self: initial;
align-self: revert;
align-self: revert-layer;
align-self: unset;

Values

auto

Computes to the parent's align-items value.

normal

The effect of this keyword is dependent of the layout mode we are in:

  • In absolutely-positioned layouts, the keyword behaves like start on replaced absolutely-positioned boxes, and as stretch on all other absolutely-positioned boxes.
  • In static position of absolutely-positioned layouts, the keyword behaves as stretch.
  • For flex items, the keyword behaves as stretch.
  • For grid items, this keyword leads to a behavior similar to the one of stretch, except for boxes with an aspect ratio or an intrinsic size where it behaves like start.
  • The property doesn't apply to block-level boxes, and to table cells.
self-start

Aligns the items to be flush with the edge of the alignment container corresponding to the item's start side in the cross axis.

self-end

Aligns the items to be flush with the edge of the alignment container corresponding to the item's end side in the cross axis.

flex-start

The cross-start margin edge of the flex item is flushed with the cross-start edge of the line.

flex-end

The cross-end margin edge of the flex item is flushed with the cross-end edge of the line.

center

The flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.

baseline, first baseline, last baseline

Specifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box's first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group. The fallback alignment for first baseline is start, the one for last baseline is end.

stretch

If the item's cross-size is auto, the used size is set to the length necessary to be as close to filling the container as possible, respecting the item's width and height limits. If the item is not auto-sized, this value falls back to flex-start, and to self-start or self-end if the container's align-content is first baseline (or baseline) or last baseline.

anchor-center

In the case of anchor-positioned elements, aligns the item to the center of the associated anchor element in the block direction. See Centering on the anchor using anchor-center.

safe

If the size of the item overflows the alignment container, the item is instead aligned as if the alignment mode were start.

unsafe

Regardless of the relative sizes of the item and alignment container, the given alignment value is honored.

Formal definition

Initial value auto
Applies to flex items, grid items, and absolutely-positioned boxes
Inherited no
Computed value auto computes to itself on absolutely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent. Its behavior depends on the layout model, as described for justify-self. Otherwise the specified value.
Animation type discrete

Formal syntax

align-self = 
auto |
normal |
stretch |
<baseline-position> |
<overflow-position>? <self-position> |
anchor-center

<baseline-position> =
[ first | last ]? &&
baseline

<overflow-position> =
unsafe |
safe

<self-position> =
center |
start |
end |
self-start |
self-end |
flex-start |
flex-end

Examples

>

HTML

<section>
  <div>Item #1</div>
  <div>Item #2</div>
  <div>Item #3</div>
</section>

CSS

section {
  display: flex;
  align-items: center;
  height: 120px;
  background: beige;
}

div {
  height: 60px;
  background: cyan;
  margin: 5px;
}

div:nth-child(3) {
  align-self: flex-end;
  background: pink;
}

Result

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
align-self 2921 1212 2049 12.1 97 2925 2049 12.1 97 2.01.5 4.44.4 97
anchor-center 125 125 No 111 26 125 No 83 26 27.0 125 26
auto 21 79 28 15 7 25 28 14 7 1.5 4.4 7
flex_context 36
21–36Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Chrome implements the new behavior beginning with Chrome 52.
12
20Before Firefox 27, only single-line flexbox is supported.
12.1 7 36
25–36Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Chrome Android implements the new behavior beginning with Chrome Android 52.
20Before Firefox for Android 27, only single-line flexbox is supported.
12.1 7 3.0
1.5–3.0Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Samsung Internet implements the new behavior beginning with Samsung Internet 6.0.
37
4.4–37Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. WebView Android implements the new behavior beginning with WebView Android 52.
7
grid_context 57 16 52 44 10.1 52 52 43 10.3 6.2 57 10.3
normal 21 79 28 15 7 25 28 14 7 1.5 4.4 7
position_absolute_context 122 122 134 108 No 122 134 81 No 26.0 122 No
stretch 21 79 28 15 7 25 28 14 7 1.5 4.4 7

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/align-self