Description & Usage

The align-items property controls alignment of flex or grid items along the cross axis (perpendicular to the main axis defined by flex-direction).

When flex-direction is row (default), align-items controls vertical alignment. When flex-direction is column, it controls horizontal alignment. The default value stretch causes items to fill the container height.

For individual item overrides, use the align-self property on specific child elements to break away from the group alignment set by align-items.

Property Specifications

Property FeatureSpecification
CategoryFlexbox
Initial Valuestretch
InheritedNo (not inherited)
Applies ToFlex and Grid containers
Flexbox Playground
Items:
4
12px
Item 1
Item 2
Item 3
Item 4
.container { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-wrap: nowrap; gap: 12px; }

Syntax

align-items: stretch | flex-start | flex-end | center | baseline;

Property Values

ValueDescription
stretchItems stretch to fill container along cross axis (respecting min/max width/height).
centerItems are centered along cross axis.
flex-startItems are aligned to start edge of cross axis.
flex-endItems are aligned to end edge of cross axis.
baselineItems are aligned such that their text baselines match.

Code Examples

Perfect Vertical Centering
.hero { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
Centers content perfectly vertically and horizontally.