align-items
Defines the default behavior for how items are aligned along the cross axis (perpendicular to the main axis) in a flex or grid container.
Quick example
.container {
display: flex;
align-items: center;
} /* centers items vertically in a row container */ Syntax
align-items: <alignment-keyword>stretchflex-startflex-endcenterbaselineQuick facts
normalExamples
Center items vertically in a row
.header {
display: flex;
align-items: center;
height: 60px;
} A classic use: vertically center a logo, nav, and buttons inside a fixed-height header.
Align text baselines across items
.pricing {
display: flex;
align-items: baseline;
}
.price {
font-size: 3rem;
}
.per-month {
font-size: 1rem;
} baseline lines up the bottom of the text characters even when font sizes differ, which looks more natural than center.
Stretch children to equal height
.card-row {
display: flex;
align-items: stretch;
} Default behavior. All cards become the same height as the tallest one, making row layouts look tidy without setting explicit heights.
align-items Browser Support
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.
Safe to use without fallbacks.
Common pitfalls
When flex-direction is column, the cross axis is horizontal. align-items now controls horizontal alignment and justify-content controls vertical. Switch containers and the property meanings swap.
align-items is the default for all items in the container. Individual items can override it with align-self. If an item is not aligning as expected, check for an align-self override.
stretch only works when the item does not have a fixed height (for row containers) or fixed width (for column containers). Setting height or width on the child defeats the stretch behavior.