CSS align-items Property Explained
What the CSS align-items property does, with an example.
Published November 4, 2026
align-items aligns flex or grid items along the cross axis: stretch (default), flex-start, center, flex-end or baseline.
How it works
In a row container it controls vertical alignment. The default stretch makes items as tall as the container.
Use align-self to override for a single item.
Values and effects
align-items: stretch; → fill the cross size
align-items: flex-start; → top
align-items: center; → middle
align-items: flex-end; → bottom
align-items: baseline; → align text baselines
Practical examples
Vertically centre
.bar { display: flex; align-items: center; height: 64px; }Baseline align mixed font sizes
.row { display: flex; align-items: baseline; }Override one item
.special { align-self: flex-end; }Common mistakes
- Container has no height so vertical centring is invisible.
- Using stretch with fixed heights on items.
- Mixing up with justify-content.
Key takeaways
- align-items in one line: align-items aligns flex or grid items along the cross axis: stretch (default), flex-start, center, flex-end or baseline.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
How do I centre both ways?
display:flex; justify-content:center; align-items:center;
Is align-items supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.