Last updated on

The align-self property is a sub-property of the Flexible Box Layout module.

It makes possible to override the align-items value for specific flex items.

The align-self property accepts the same 5 values as the align-items:

  • flex-start: cross-start margin edge of the item is placed on the cross-start line
  • flex-end: cross-end margin edge of the item is placed on the cross-end line
  • center: item is centered in the cross-axis
  • baseline: items are aligned such as their baseline are aligned
  • stretch (default): stretch to fill the container (still respect min-width/max-width)

Syntax

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

.flex-item {
  align-self: flex-end;
}

Demo

The following demo shows how an item can align itself in the flex container depending on thealign-self value:

  • The 1st item is set to flex-start
  • The 2nd item is set to flex-end
  • The 3rd item is set to center
  • The 4th item is set to baseline
  • The 5th item is set to stretch
<ul class="flex-container">
  <li class="flex-item flex-start">1</li>
  <li class="flex-item flex-end">2</li>
  <li class="flex-item center">3</li>
  <li class="flex-item baseline">4</li>
  <li class="flex-item stretch">5</li>
</ul>
.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;
  height: 200px;
  
  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;
}

.flex-start { -webkit-align-self: flex-start; align-self: flex-start; }
.flex-end { -webkit-align-self: flex-end; align-self: flex-end; }
.center { -webkit-align-self: center; align-self: center; }
.baseline { -webkit-align-self: baseline; align-self: baseline; }
.stretch { -webkit-align-self: stretch; align-self: stretch; }

.flex-item {
  background: tomato;
  padding: 5px;
  width: 100px;
  margin: 5px;
  
  line-height: 100px;
  color: white;
  font-weight: bold;
  font-size: 2em;
  text-align: center;
}

Related Properties

Browser Support

  • (modern) means the recent syntax from the specification (e.g. display: flex;)
  • (hybrid) means an odd unofficial syntax from 2011 (e.g. display: flexbox;)
  • (old) means the old syntax from 2009 (e.g. display: box;)
Chrome Safari Firefox Opera IE Android iOS
21+ (modern)
20- (old)
3.1+ (old) 2-21 (old)
22+ (new)
12.1+ (modern) 10+ (hybrid) 2.1+ (old) 3.2+ (old)

Blackberry browser 10+ supports the new syntax.