🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS align-self

Override flex container alignment. Learn to control individual flex items with precision.

layout.css
.container {
display: flex;
align-items: flex-start;
}
.item-2 {
align-self: flex-end;
}
style.css
1 / 9
1
2
3
🧘

Tutor:In Flexbox, `align-items` controls the alignment of ALL items on the cross-axis. But what if one item needs to be different?


Flexbox Mastery

Unlock nodes by learning Flexbox alignment properties.

Concept 1: The Flex Container

Before using alignment properties, elements must be inside a container with display: flex or display: inline-flex.

System Check

Which property establishes a flex context?


Community Layouts

Share Layout Patterns

Created a cool navigation bar or grid using alignment? Share your CSS snippets.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Align-Self Property

Author

Pascual Vila

Frontend Instructor.

The align-self property allows the default alignment (or the one specified by align-items) to be overridden for individual flex items. This is crucial for creating complex layouts where one element needs to behave differently from its siblings.

Understanding the Context

In a Flexbox container, the align-items property is set on the parent. It dictates how all children align along the Cross Axis. align-self is the exception to this rule, applied directly to the child.

Common Values

  • auto: Inherits the value of the parent's align-items property.
  • flex-start: Aligns the item to the start of the cross-axis (usually top).
  • flex-end: Aligns the item to the end of the cross-axis (usually bottom).
  • center: Centers the item on the cross-axis.
  • stretch: Stretches the item to fill the container (default if height is auto).

When to Use

Use align-self when you have a row of items (like a navigation bar) where most items are centered, but one item (like a "Sign Up" button or logo) needs to be aligned to the top or stretched.

Alignment Glossary

align-self
CSS property applied to a single flex item to override the container's align-items setting.
align-items
CSS property applied to the flex container to set the default alignment for all child items on the cross-axis.
Cross Axis
The axis perpendicular to the main axis. If flex-direction is row, the cross axis is vertical.