The align-items property controls how flex items or grid items are aligned along the cross axis inside their container. It is one of the most useful Flexbox tools for vertically centering content or lining up items of different heights.
01
Cross-Axis Items
Align items inside one row.
02
Syntax
Apply it on the container.
03
Flexbox
Center, stretch, or pin items.
04
CSS Grid
Default alignment for grid items.
05
Baseline
Line up text cleanly.
06
vs align-content
Items, not whole lines.
Fundamentals
Definition and Usage
The align-items CSS property sets the default alignment for flex items or grid items on the cross axis. In a row-direction flex container, the cross axis is vertical, so align-items often controls how items sit top-to-bottom inside the row.
It affects every item in the container unless an item overrides it with align-self. This makes it perfect for centering icons beside text, equal-height cards in a row, or baseline-aligned labels.
💡
Beginner Tip
Give the flex container a cross-axis size such as height or min-height when you want vertical alignment like center or flex-end to be visible.
Set align-items on the flex or grid container, not on individual items.
The default value is stretch, which fills the cross-axis size of the flex line.
Use align-self on a single item when you need an exception.
In a column-direction flex container, the cross axis is horizontal.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
stretch (flexbox), normal (grid)
Applies to
Flex containers and grid containers
Inherited
No
Animatable
No
Common use
Vertically centering items in a flex row
Defaults
Default Value
The initial value of align-items is stretch in flexbox. Flex items stretch to fill the container’s cross-axis size unless they have an explicit height or width on that axis.
Reference
💎 Property Values
These keyword values control how items align inside a single flex line or grid area.
Value
Example
Meaning
stretch
align-items: stretch;
Items stretch to fill the flex line on the cross axis
flex-start
align-items: flex-start;
Items align to the start of the cross axis
flex-end
align-items: flex-end;
Items align to the end of the cross axis
center
align-items: center;
Items are centered on the cross axis
baseline
align-items: baseline;
Items align to their text baselines
normal
align-items: normal;
Grid default behavior; in flexbox behaves like stretch
stretch
Default behavior. Items expand to the full height of the flex line.
Flex container
ABC
Cross axis
center
Items of different heights are centered along the cross axis.
Flex container
ABC
Cross axis
flex-end
Items align to the bottom of the cross axis in a row flex container.
Flex container
ABC
Cross axis
Compare
align-items vs align-content
Property
What it aligns
Best for
align-items
Individual items inside one line or track
Centering or stretching items in a single flex row
align-content
Whole lines or tracks as a group
Spacing multiple wrapped rows inside a container
Preview
👀 Live Preview
This flex container uses align-items: center to vertically center three items inside a fixed-height row:
Item 1
Item 2
Item 3
Hands-On
Examples Gallery
Try align-items with centered items, stretch, flex-end, and baseline text alignment.
📚 Flexbox Alignment
These examples show how align-items moves items along the cross axis inside a single flex row.
Example 1 — Center Items on the Cross Axis
Center flex items vertically inside a fixed-height container. This is one of the most common Flexbox patterns.
Baseline alignment lines up the text bottoms instead of the box edges, which looks more natural for typography.
🧠 How align-items Works
1
The container creates a flex line
Flex items are placed on a line along the main axis. In a row layout, they sit side by side.
Layout
2
align-items picks the cross-axis rule
Values like center, stretch, or baseline set the default alignment for every item.
Alignment
3
Items move within the line
Each item is positioned on the cross axis inside the flex line. Use align-self to override one item.
Items
=
📦
Clean cross-axis alignment
Items line up the way you expect vertically or horizontally, depending on flex direction.
Compatibility
Universal Browser Support
align-items is supported in all modern browsers for both flexbox and CSS Grid layouts.
✓ Baseline · Flexbox & Grid
Cross-axis alignment you can rely on
Chrome, Firefox, Safari, Edge, and Opera all support align-items in current versions.
98%Modern browser support
Google Chrome29+ flex · 57+ grid
Full support
Mozilla Firefox28+ flex · 52+ grid
Full support
Apple Safari9+ flex · 10.1+ grid
Full support
Microsoft Edge12+ flex · 16+ grid
Full support
OperaModern versions
Full support
align-items property98% supported
Bottom line: Use align-items confidently in modern flexbox and grid layouts.
Wrap Up
Conclusion
The align-items property is an essential part of Flexbox and Grid. It gives you a simple way to control how items align on the cross axis inside a single row or grid area.
For beginners, remember: use align-items for individual items, and align-content when you are spacing multiple wrapped lines. Try center for vertical centering and baseline for text.
Set a cross-axis size on the container when using center or flex-end
Use align-items: center for icon + text rows
Use baseline for mixed font sizes in one row
Override one item with align-self when needed
Pair with justify-content for full alignment control
❌ Don’t
Confuse align-items with align-content
Expect vertical centering without container height
Apply align-items directly to flex items
Use stretch when items already have fixed cross-axis sizes
Forget that column flex direction swaps the cross axis
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about align-items
Use these points when aligning flex and grid items.
5
Core concepts
📦01
Item Alignment
Aligns items inside one line.
Purpose
📐02
Cross Axis
Often vertical in row flex.
Axis
🛠03
Default
stretch fills the line.
Values
🔄04
Flex + Grid
Works in both layout systems.
Scope
📝05
Baseline
Best for mixed text sizes.
Typography
❓ Frequently Asked Questions
The align-items property controls how flex items or grid items are aligned along the cross axis inside their flex line or grid area.
align-items aligns individual items within one line or track. align-content aligns multiple lines or tracks as a group when extra cross-axis space exists.
The initial value is stretch. Items stretch to fill the flex line or grid area on the cross axis unless they have an explicit size.
Yes. In grid layouts, align-items sets the default alignment for grid items along the block axis inside their grid areas.
Use baseline when aligning text or inline content of different font sizes so their text baselines line up cleanly.