HTML & CSS - Mastery / Flexbox Mastery

Align-self

🧘 Align Self in Action

The align-self property allows a single flex item to override the container’s align-items value — giving you individual alignment control on the cross axis (vertical by default).


📘 Why Use align-self?

While align-items sets alignment for all flex items, align-self lets one item break free and align differently.

This is great when you want exceptions in a row or column layout — for example, highlighting a featured card, aligning one button to the bottom, or creating asymmetric designs.


🧱 Syntax

.flex-item {
  align-self: auto | flex-start | flex-end | center | baseline | stretch;
}

Values:

Value

Description

auto

Inherits from align-items (default behavior)

flex-start

Align to the start of the cross axis

flex-end

Align to the end of the cross axis

center

Center along the cross axis

baseline

Align with the text baseline of other items

stretch

Stretch to fill the container (default for align-items)


📦 Example

  • All items align to the top due to align-items: flex-start

  • The “Special” item aligns to the bottom using align-self: flex-end


🧠 Use Cases

  • Highlight a single item in a card layout

  • Vertically align a button or icon differently

  • Create dynamic stacking effects in complex UI


⚠️ Notes

  • Works only on flex items

  • Overrides the parent’s align-items only for that item

  • Doesn’t affect main axis alignment — use justify-content for that