Questions
19 of 51
1What is Flexbox in CSS?
2What problem does Flexbox solve compared to traditional layouts like float or inline-block?
3How do you create a flex container?
4What are the main and cross axes in Flexbox?
5What does the display: flex property do?
6What is the difference between display: flex and display: inline-flex?
7What are flex items?
8How do you change the direction of items in a flex container?
9What does flex-direction: row do?
10What does flex-direction: column do?
11What is the purpose of the justify-content property?
12What does the align-items property control?
13What are the possible values of align-content?
14What is the difference between align-items and align-content?
15What is the use of the flex-wrap property?
16How can you make flex items wrap onto multiple lines?
17What does the flex-flow shorthand property do?
18How does the order property affect flex items?
19How does the align-self property work?
20How do you vertically center content using Flexbox?
21What does the flex shorthand property represent?
22What are the three components of the flex shorthand property?
23What is the default value of the flex property?
24How do flex-grow, flex-shrink, and flex-basis work individually?
25What is the difference between flex: 1 and flex: auto?
26What is the difference between flex: 1 and flex: auto?
27What is the purpose of the gap property in Flexbox?
28How does Flexbox handle overflowing content?
29What’s the difference between justify-content: space-around and space-between?
30How does Flexbox handle fixed and flexible widths together?
31Can Flexbox be nested?
32How is Flexbox different from CSS Grid?
33When would you use Flexbox instead of Grid?
34Can you use Flexbox and Grid together in the same layout?
35How does Flexbox differ from traditional float-based layouts?
36Does Flexbox affect the box model or positioning of elements?
37How does Flexbox handle min-width and max-width constraints?
38How do flex items align when the container has align-items: stretch?
39What is the difference between flex: 0 1 auto and flex: 1 0 auto?
40How does flex-basis differ from width?
41How do you prevent a flex item from shrinking?
42How would you create a horizontal navigation bar using Flexbox?
43How do you center a div both horizontally and vertically using Flexbox?
44How can you make a responsive layout using Flexbox?
45How can you make one flex item take up the remaining space in a container?
46How do you create equal-height columns using Flexbox?
47How can you align the last flex item to the right side of the container?
48How can you reorder items visually using Flexbox without changing the HTML structure?
49How can you make items stack vertically on mobile and horizontally on desktop using Flexbox?
50How do you prevent an element from wrapping in a flex container?
51How can you align items to the bottom of a container using Flexbox?
19 / 51

How does the align-self property work?

Understanding the align-self Property in Flexbox

The align-self property in CSS allows individual flex items to override the container’s align-items setting. It controls how a specific item is aligned along the cross axis (perpendicular to the main axis). This makes it useful when you need a single item to have a different alignment than the others in the same flex container.

Syntax
  1. 1

    align-self: auto | flex-start | flex-end | center | baseline | stretch;

  2. 2

    Default value is auto, which means the item inherits the container’s align-items value.

Possible Values
  1. 1

    auto: Inherits from the container’s align-items property.

  2. 2

    flex-start: Aligns the item at the start of the cross axis.

  3. 3

    flex-end: Aligns the item at the end of the cross axis.

  4. 4

    center: Centers the item along the cross axis.

  5. 5

    baseline: Aligns the item’s baseline with other items.

  6. 6

    stretch: Stretches the item to fill the container (default if height is auto).

Example: Using align-self in a Flex Container

In this example, all items are aligned to the center of the container by default, but Item 2 moves to the bottom (flex-end), and Item 3 moves to the top (flex-start) because of their align-self values.

Best Practices
  1. 1

    Use align-self to override alignment for specific flex items without changing the container’s layout.

  2. 2

    Combine with align-items for consistent yet flexible layouts.

  3. 3

    Avoid overusing different alignments within the same container for cleaner design consistency.

Difficulty: 3/10
Topics: flexbox alignment, individual item control, override of align-items

Scenario Questions

0-2 years experience
  1. 1

    You have a flex container with align-items: center, but one button inside needs to be aligned to the top — how would you fix that?

  2. 2

    A card component’s image is stretching too much vertically while the text below is centered — what CSS property would you use to make the image align to the top without affecting the text?

  3. 3

    If you set align-self: flex-end on a flex item but it doesn’t move, what’s the first thing you’d check?

2-5 years experience
  1. 1

    A responsive navigation bar breaks on mobile: the logo is misaligned after switching from row to column layout — how would you debug and fix it using align-self?

  2. 2

    Your team’s design system uses a shared flex container for cards, but one variant needs a different vertical alignment — how do you implement this without breaking other cards or adding excessive CSS?

  3. 3

    A modal popup has inconsistent alignment across browsers — some items are off by a few pixels. You suspect align-self is involved. What would you investigate?

5-8 years experience
  1. 1

    You’re designing a dynamic dashboard with user-placed widgets in a flex container — how would you architect the alignment system so editors can override default alignment per widget without causing layout thrashing or performance issues?

  2. 2

    A legacy component library uses align-self inconsistently across components, leading to visual bugs in new layouts. How would you refactor this at scale while maintaining backward compatibility?

  3. 3

    In a high-performance UI with hundreds of flex items, how might overuse of align-self impact rendering performance or layout recalculations? When would you avoid it?

8+ years experience
  1. 1

    You’re leading the migration from a legacy float-based layout system to flexbox across 50+ products — how do you handle teams that misuse align-self to patch alignment issues instead of fixing the underlying container structure?

  2. 2

    How would you design a design token system for alignment that allows product teams to customize align-self behavior without creating visual fragmentation across the UI system?

  3. 3

    An enterprise app has inconsistent vertical alignment in sidebars across different regions due to inherited align-self values. How would you enforce alignment consistency at the architecture level without forcing rigid component boundaries?

Follow-up Questions

  • What happens if you set align-self: auto on a flex item?
  • How does align-self behave differently in a column-direction flex container?
  • Can align-self be used in grid layouts the same way?