CSS align-items Property

Beginner
7 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The align-items property lines up every direct child inside its flex line or grid area. In a row flex, that is the vertical position: items move up, down, or stretch inside that one line.

One line is enough. align-self on a single child overrides the group. This property does not pack extra lines. Use align-content for that.

Standard-track.

Not deprecated and not experimental. Flex and grid values are widely supported. anchor-center is newer and only applies to anchor-positioned boxes.

CSS Syntax

syntax.css
align-items: normal | stretch | center | flex-start | flex-end | baseline | initial | inherit;

Property Values

ValueDescriptionTry it
normalDefault. In flex and grid this behaves like stretchTry it
stretchItems whose cross size is auto grow to fill the lineTry it
centerCenters each item inside the lineTry it
flex-startPacks items against the start of the cross axisTry it
flex-endPacks items against the end of the cross axisTry it
baselineLines up the text baselines of the itemsTry it
initialSets this property to its default value, normalTry it
inheritInherits this property from the parent elementTry it

How to Use align-items

Put it on the container. The children follow, unless one of them sets align-self.

  1. Set display: flex or display: grid on the container.
  2. Give the line a cross size you can see. For a row flex, that is usually height.
  3. Set align-items on the container. It is not inherited.
  4. Leave the item's cross size as auto if you want stretch. A fixed height on a row item blocks stretch.
PieceRequired?Role
Flex or grid containerYesThe parent that owns the items
Cross size on the lineYes, to see itA row needs height. A column needs width
KeywordYescenter, flex-start, flex-end, stretch, baseline
align-selfOptionalOverrides the group value on one item

Live Preview

Three items share one flex line. The middle word is larger so baseline is visible.

One line in a tall row. align-items moves the items inside that line.

Items
One
Two
Three

align-items: center

CSS Examples

Each snippet only adds what align-items needs: a flex row, a height, and the keyword. Use Try It Yourself for a live editor.

Example 1 — Center on the Cross Axis

Place every item in the vertical middle of a tall row.

CSS
<style>
  section {
    display: flex;
    height: 120px;
    align-items: center;
    border: 1px solid #ccc;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
</section>
Try It Yourself

How It Works

  1. Make one row. display: flex puts One, Two, and Three on a single line. Wrap is not required.
  2. Give the line a height. height: 120px is taller than the text. The border shows that spare space.
  3. Center the items. align-items: center places each item's margin box in the middle of the line.
  4. The words stay as they are. This does not change font size or center text inside a stretched box. It centers the item itself.

Example 2 — Pack to the End

Sit every item on the bottom edge of the same row.

CSS
<style>
  section {
    display: flex;
    height: 120px;
    align-items: flex-end;
    border: 1px solid #ccc;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
</section>
Try It Yourself

How It Works

  1. Same tall row. The line is still 120px. The items are still only as tall as their text.
  2. Pick the cross-end edge. In a row, flex-end is the bottom. flex-start would be the top.
  3. Pack every item there. The spare space sits above the items. They share one edge.
  4. One item can opt out. align-self on a single child replaces this group value for that child only.

Example 3 — Stretch to the Line

Let auto-sized items grow until their boxes match the line height.

CSS
<style>
  section {
    display: flex;
    height: 120px;
    align-items: stretch;
    border: 1px solid #ccc;
  }
  div {
    border: 1px solid #999;
  }
</style>

<section>
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
</section>
Try It Yourself

How It Works

  1. Ask for stretch. align-items: stretch is also what normal does for flex items, so this is the default look.
  2. Leave height alone. The divs have no height, so the cross size is auto and stretch is allowed to grow them.
  3. Fill the line. Each box grows to the 120px line. The item border is there so you can see the box, not only the word.
  4. Text stays at the start of the box. Stretch changes the box size. It does not vertically center the word inside that box.

Edge Cases & Pitfalls

If the items do not move, one of these is usually why.

height

stretch loses to a fixed cross size

A height on a row item, or a width on a column item, blocks stretch. The item then packs like flex-start.

lines

align-content is a different job

align-content moves wrapped lines. align-items moves items inside a line. You do not need flex-wrap for align-items.

self

One child can override the group

align-self on an item replaces align-items for that item. The others stay with the container.

axis

A column flex flips the axis

With flex-direction: column, align-items is horizontal. center then centers items left to right, and you need spare width to see it.

safe

center can overflow both ways

If an item is taller than the line, center overflows equally above and below. safe center falls back to start when that overflow would hide content.

Browser Support

align-items is a browser layout property for flex and grid. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Flex since 2015

align-items

Flex: Chrome 29+, Firefox 28+, Safari 9+, Edge 12+. Grid: Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+. Internet Explorer 11 is flex-only.

96% Flex and grid support
Google Chrome 29+ flex · 57+ grid
Full support
Mozilla Firefox 28+ flex · 52+ grid
Full support
Apple Safari 9+ flex · 10.1+ grid
Full support
Microsoft Edge 12+ flex · 16+ grid
Full support
Opera 16+ flex · grid in Chromium 57+
Full support
Samsung Internet 4+ flex · 6.2+ grid
Full support
Internet Explorer 11 · Old flex only
Partial
align-items Widely supported

Bottom line: Safe for flex and grid in current browsers. Internet Explorer 11 is flex-only, and a centered column item can overflow its container there. anchor-center needs Chrome 125, Safari 26, or Firefox 147, and only affects anchor-positioned boxes. safe needs Chrome 115, Firefox 63, or Safari 17.6.

Key Takeaways

  • Role: line up every direct child inside its flex line or grid area.
  • Row flex: the cross axis is vertical. One line is enough. Give the row a height to see it.
  • Not align-content: content moves lines. Items moves the items inside a line.
  • Default: normal stretches flex items whose cross size is auto. It is not inherited.

One line: align-items places each item inside the line — center, end, or stretch — without touching how the lines themselves are packed.

Frequently Asked Questions

It sets how every direct child lines up inside its flex line or grid area, on the cross axis. In a row flex, that is the vertical position. It does not move the lines themselves.
align-items moves items inside one line. align-content moves the lines when there is more than one and the container has spare space. A single row can use align-items without flex-wrap.
Stretch only grows an item whose cross size is auto. A set height on a row item, or a set width on a column item, blocks it. The item then falls back to flex-start.
Yes. In a grid it aligns each item inside its grid area on the block axis. The default normal behavior is similar to stretch, except some replaced boxes and items with an aspect ratio start at the start edge instead.
Yes. align-self on that item replaces the group value from align-items. The other items keep the container's alignment.
Flex support is in Chrome 29+, Firefox 28+, Safari 9+, and Edge 12+. Grid support starts at Chrome 57, Firefox 52, and Safari 10.1. Internet Explorer 11 only has the old flex behavior. It is a browser layout property, not a Node.js feature.

Next: align-self

Learn how one flex or grid item can ignore the container's align-items value.

align-self tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful