CSS Portal

CSS align-self Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The align-self CSS property allows you to override how an individual item is aligned inside a flex or grid container, independently of the other items. While layout alignment is often controlled at the container level, align-self gives you fine-grained control over a single element’s position along the cross axis. This makes it especially useful when one item needs to visually stand out, sit higher or lower, or behave differently from its siblings without changing the overall layout structure.

In a flex layout, align-self works in relation to the container’s alignment rules, typically defined by align-items. When applied, it overrides the container’s alignment setting for that specific element only. This is helpful in responsive designs where most elements follow a consistent pattern, but one item - such as a button, icon, or label - needs a custom alignment. In grid layouts, align-self controls how an item aligns within its own grid area, giving you precise control without affecting other grid items.

The behavior of align-self also depends on the layout direction defined by the container. For example, when used in a flex container that flows in a column direction (controlled by flex-direction), the cross axis changes, and so does the visual effect of alignment. This adaptability makes align-self a powerful tool for building flexible and responsive interfaces. It pairs especially well with modern layout techniques, allowing developers to create polished designs without resorting to extra wrappers or complex positioning logic.

Definition

Initial value
auto
Applies to
Flex items, grid items, and absolutely-positioned boxes
Inherited
No
Computed value
Specified value
Animatable
yes
JavaScript syntax
object.style.alignSelf

Interactive Demo

One
Two
Three

Syntax

align-self: auto | flex-start | flex-end | center | baseline | stretch

Values

  • autoTakes the parent value of align-items or stretch if there is no parent.
  • flex-startThe element is aligned at the beginning of the transverse axis of the container.
  • flex-endThe element is aligned at the end of the transverse axis of the container.
  • centerThe element is aligned in the center line on the transverse axis.
  • baselineThe element is aligned with the baseline of the text.
  • stretchThe element is stretched in such a way as to occupy the entire free space of the container along the transverse axis.

Example

<div class="example">
<h2>align-self demo</h2>
<div class="container">
<div class="item">Default</div>
<div class="item align-start">flex-start</div>
<div class="item align-center">center</div>
<div class="item align-end">flex-end</div>
<div class="item align-stretch">stretch</div>
</div>
</div>
.example {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  padding: 20px;
}

.container {
  display: flex;
  height: 160px;
  gap: 12px;
  align-items: center; /* default cross-axis alignment */
  padding: 12px;
  border: 2px dashed #e0e0e0;
  background: #fafafa;
}

.item {
  padding: 12px 16px;
  min-width: 80px;
  background: #4a90e2;
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.align-start {
  align-self: flex-start;
  background: #7b61ff;
}

.align-center {
  align-self: center;
  background: #4a90e2;
}

.align-end {
  align-self: flex-end;
  background: #e94e77;
}

.align-stretch {
  align-self: stretch;
  background: #50e3c2;
}

Browser Support

The following information will show you the current browser support for the CSS align-self property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!