Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape

CSS Align Items

CSS Align Items

CSS CODES & EXAMPLES

CSS Align Items

Learn how the CSS align-items property controls the alignment of flex items across the cross axis of a flex container.

01

What is Align Items?

Control alignment on the cross axis

The align-items property defines how flex items are aligned on the cross axis of a flex container.

Remember: With flex-direction: row, the cross axis is vertical. With flex-direction: column, the cross axis is horizontal.
02

Syntax

Basic CSS syntax
align-items.css
.container {
  display: flex;
  align-items: center;
}
03

align-items: stretch

Default value

stretch makes flex items stretch across the cross axis when their cross-size is not explicitly defined.

stretch.css
.container {
  display: flex;
  align-items: stretch;
}
1
2
3
04

align-items: flex-start

Align items at the beginning

flex-start places the flex items at the beginning of the cross axis.

flex-start.css
.container {
  display: flex;
  align-items: flex-start;
}
1
2
3
05

align-items: flex-end

Align items at the end

flex-end moves the flex items to the end of the cross axis.

flex-end.css
.container {
  display: flex;
  align-items: flex-end;
}
1
2
3
06

align-items: center

Center items on the cross axis

center places the flex items in the center of the cross axis. This is one of the most commonly used Flexbox values.

center.css
.container {
  display: flex;
  align-items: center;
}
1
2
3
08

Align Items Comparison

See the difference visually
flex-start
1 2 3
center
1 2 3
flex-end
1 2 3
stretch
1 2 3
09

Align Items with Row

Vertical cross axis
row.css
.container {
  display: flex;
  flex-direction: row;
  align-items: center;
}
HTML
CSS
JavaScript

With flex-direction: row, the cross axis is vertical. Therefore, align-items: center vertically centers the items.

10

Align Items with Column

Horizontal cross axis
column.css
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
HTML
CSS
JavaScript

When the direction is column, the cross axis becomes horizontal. Therefore, align-items: center centers the items horizontally.

11

Justify Content vs Align Items

Understand the two important Flexbox properties
PropertyControlsRow DirectionColumn Direction
justify-content Main axis Horizontal Vertical
align-items Cross axis Vertical Horizontal
12

Practical Website Example

Center content inside a card

A common website layout uses align-items: center to vertically align an icon, title, and button inside a horizontal card.

card.css
.course-card {
  display: flex;
  align-items: center;
  gap: 20px;
}

.course-icon {
  width: 70px;
  height: 70px;
}
CSS

Web Designing Course

Learn HTML, CSS and responsive website design.

View Course
13

Quick Reference

Common align-items values
stretch

Stretches items across the cross axis.

flex-start

Moves items to the start of the cross axis.

flex-end

Moves items to the end of the cross axis.

center

Centers items on the cross axis.

baseline

Aligns items according to their text baseline.

15

Practice Task

Create a perfectly aligned course card

🎯 Build a Course Information Card

Create a horizontal course card containing an icon, course information and an enrollment button.

  • Use display: flex;
  • Use align-items: center;
  • Add gap: 20px;
  • Add a course icon on the left.
  • Add course title and description.
  • Add an action button on the right.
16

CSS Align Items Live Example

Run the practical example
LIVE PREVIEW
`;document.getElementById( "sncecAIPreview" ).srcdoc=html;}document.addEventListener( "DOMContentLoaded", function(){sncecAIRun();} );

CSS Z-Index

  • 18/08/2026

HTML Paragraph

  • 17/08/2026

Leave a Reply

Your email address will not be published. Required fields are marked *