The align-items property

align-items is set on a flex or grid container and aligns all its items along the cross axis: it stretches them to full height, centers them or packs them at the start or end.

Syntax

align-items: normal | stretch | flex-start | center | flex-end | baseline;
Initial value
normal
Inherited
no
Applies to
all elements; the effect is visible in flex and grid containers

Values

ValueWhat it does
normalthe initial value; in flex and grid containers it behaves as stretch
stretchitems stretch to the full height of the line (unless they have a set height)
flex-startitems at the start of the cross axis — the top for a row
centerin the center of the cross axis
flex-endat the end of the cross axis — the bottom for a row
baselinealong the baseline of the first line of text — handy when font sizes differ

Example

.row {
  display: flex;
  gap: 8px;
  height: 90px;
  padding: 8px;
  margin-bottom: 8px;
  background: #f1f5f9;
}
.row span {
  padding: 6px 10px;
  background: #0284c7;
  color: #fff;
}
.row span:nth-child(2) { font-size: 24px; }
.stretch { align-items: stretch; }
.center { align-items: center; }
.end { align-items: flex-end; }
.baseline { align-items: baseline; }
<p>stretch</p><div class="row stretch"><span>1</span><span>2</span><span>3</span></div>
<p>center</p><div class="row center"><span>1</span><span>2</span><span>3</span></div>
<p>flex-end</p><div class="row end"><span>1</span><span>2</span><span>3</span></div>
<p>baseline</p><div class="row baseline"><span>1</span><span>2</span><span>3</span></div>

Result

▶ Open in HTML Editor

Good to know

  • The cross axis is perpendicular to the main axis: with flex-direction: row it is vertical, with column it is horizontal.
  • stretch does not stretch an item that has a height set (or a width, in a column).
  • To center on both axes: justify-content: center and align-items: center on the container.
  • A single item can be aligned differently with align-self; in a grid container align-items aligns items inside their cells.

Sources and specification

See also