align-items
Widely availableSince 201597% of users
Defines the default behavior for how items are aligned along the cross axis (perpendicular to the main axis) in a flex or grid container.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyClassic, with newer partsIt has worked everywhere since September 2015, and it keeps getting newer values.
Newer parts of align-items
anchor-centerBaseline Jan 2026safeBaseline Jul 2024unsafeBaseline Jul 2024last baselineBaseline Dec 2022, Widely Jun 2025self-endBaseline Jul 2022, Widely Jan 2025self-startBaseline Jul 2022, Widely Jan 2025baselineBaseline Jan 2020, Widely Jul 2022endBaseline Jan 2020, Widely Jul 2022
See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
normal- Inherited
- No
- Applies to
- Flex and grid containers
- Animation type
- discrete
Quick example
.container {
display: flex;
align-items: center;
} /* centers items vertically in a row container */Syntax
align-items: <alignment-keyword>stretch- Items stretch to fill the container on the cross axis (respecting min/max constraints). This is the default for flex and grid.
flex-start- Items align to the start of the cross axis. In a row container, that is the top edge.
flex-end- Items align to the end of the cross axis. In a row container, that is the bottom edge.
center- Items center along the cross axis.
baseline- Items align so their text baselines sit on the same line. Useful when items have different font sizes.
Examples
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.
Common pitfalls
- Cross axis flips with flex-directionWhen 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 only sets the defaultalign-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 needs no fixed cross-axis sizestretch 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.
See also
align-items browser support
BaselineWidely availableThis 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.
Usage97%of people can use this3% use a browser without it.
Browsers
29+
20+
9+
12+Mobile
29+Android
20+Android
9+iOS