Course contentsShow
← Web Development
Lesson 285 of 2,9825. FlexboxFree lesson

align-self: Individual Item Alignment

Override the container's align-items for specific flex items.

align-self: Individual Item Alignment

You'll learn how to override the flex container's alignment for individual flex items, giving you precise control over where specific items appear on the cross axis.

The Core Idea

Remember how align-items sets cross-axis alignment for all flex items in a container? Sometimes you need one or two items to align differently than the rest. That's exactly what align-self does—it's applied directly to a flex item (not the container) and overrides the container's align-items setting for just that item.

Think of it like a classroom where the teacher says "everyone line up against the wall" (align-items: flex-start), but then tells one student "you stand in the center instead" (align-self: center). That one student breaks the pattern while everyone else follows the original rule.

How It Works

The align-self property accepts the same values as align-items:

  • auto (default) — inherits the container's align-items value
  • flex-start — aligns to the start of the cross axis
  • flex-end — aligns to the end of the cross axis
  • center — centers on the cross axis
  • stretch — stretches to fill the container's cross axis
  • baseline — aligns along the text baseline
.container {
  display: flex;
  align-items: flex-start; /* All items start at top */
}

.special-item {
  align-self: flex-end; /* This one goes to bottom */
}

This is incredibly useful for creating visual interest, handling items with different content heights, or building asymmetric layouts while keeping most items aligned uniformly.

Key Takeaway: align-self overrides the container's align-items for individual flex items, letting you fine-tune cross-axis positioning on a per-item basis.