Cross Axis Alignment Property

Last updated: 2026-09-13

align-items Cross Axis Alignment Property

The align-items property sets the alignment of all flex items on the cross axis, controlling their position in the direction perpendicular to the main axis. Its default value is stretch, which makes the items stretch to fill the container height along the cross axis. The property is commonly used for vertical centering, top alignment, bottom alignment and baseline alignment.

Category
Initial Valuenormal
InheritedNo
Applies Toall
Animation Typediscrete
CSS VersionCSS3
StatusStandard

📝 Syntax

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

⚙️ Values

ValueTypeDescription
normal | stretch | flex-start | flex-end | center | baselineKeywordCross axis alignment

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
align-items v29 v12 v28 v9 v17
Supported in all major browsers
Tip: Pairing justify-content: center with align-items: center centers flex items both horizontally and vertically - one of the most common centering recipes in flexbox.
Warning: baseline aligns the items on their text baselines, which is useful when font sizes differ. If an item has no text content, its bottom edge is treated as the baseline, which can produce unexpected results.

❓ FAQ

QWhat is the difference between align-items and align-self?
Aalign-items is set on the flex container and gives every child the same cross-axis alignment. align-self is set on a single flex item and overrides the container’s default for that item only, which is exactly what you need when one item should stand out while the rest keep the container’s alignment. align-self always has higher priority than align-items. The pair justify-items and justify-self follows the same container-default versus per-item-override relationship.
QWhy doesn’t align-items: center vertically center my items?
Aalign-items works on the cross axis. If the container has no explicit height and its height is determined by the content, there is no leftover space on the cross axis, so the centering cannot be seen. One common trap: with the default align-items: stretch and no height on the container, centering appears to do nothing because the cross axis has no leftover space to work with. Give the container a defined height, for example height: 200px. To center on the main axis at the same time, add justify-content: center.
QWhy doesn’t align-items: stretch work?
Astretch only applies when the items have no explicit cross-axis size. With a row main axis, if an item sets height, stretch is overridden and the item renders at its own height. Likewise, if the container has no definite size on the cross axis, there is nothing to stretch into. To make stretch work, keep the items’ cross-axis size at auto and give the container a definite size in that direction.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏