Questions
6 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?
06 / 51

What is the difference between display: flex and display: inline-flex?

Understanding display: flex vs display: inline-flex

display: flex and display: inline-flex both create a flex container for laying out child elements, but they differ in how the container itself behaves in the document flow.

Key Differences
  1. 1

    display: flex creates a block-level flex container, meaning the container behaves like a block element: it stretches to fill the available width and starts on a new line.

  2. 2

    display: inline-flex creates an inline-level flex container, meaning the container behaves like an inline element: it only takes up as much width as its content and can sit inline with other elements.

  3. 3

    Both make the container's direct children flex items, which can be aligned and distributed along the main and cross axes using Flexbox properties.

  4. 4

    Use display: flex for full-width layouts or stacking elements vertically, and inline-flex when you want the container to flow inline with text or other elements.

Example: Flex vs Inline-Flex

In this example, .block-flex stretches across the full width as a block-level container, while .inline-flex only takes the width of its items and flows inline with surrounding text.

Best Practices
  1. 1

    Use flex for block-level container layouts and overall page structure.

  2. 2

    Use inline-flex when embedding flex layouts inline with text or other inline elements.

  3. 3

    Understand the effect of container display on layout flow to prevent unexpected wrapping or spacing issues.

  4. 4

    Test across different browsers to ensure consistent behavior, especially when combining with inline content.

Difficulty: 3/10
Topics: flex container behavior, inline-level layout, parent-child layout context

Scenario Questions

0-2 years experience
  1. 1

    You're building a navigation link with a small icon next to the text, and you want them to stay on the same line without wrapping. You used display: flex, but the whole link is breaking onto its own line. What’s the likely cause and how would you fix it?

  2. 2

    You have a row of three buttons that should sit inline with surrounding text, like a tag cloud. You set display: flex on each button, but they’re stacking vertically. What property are you probably missing?

  3. 3

    If you set display: inline-flex on a div that contains two child elements, how does its width behave compared to if you used display: flex?

2-5 years experience
  1. 1

    A designer says the ‘Add to Cart’ button should sit inline with a product title, but when we use flex, it breaks the line. We switched to inline-flex and now it works, but the button’s height is inconsistent with the text. What’s going on and how do you fix it?

  2. 2

    We have a component that renders inline badges next to headings. We used inline-flex to align icons and text, but on mobile, the badges sometimes overflow the container. Why might this happen, and what layout strategy would you consider instead?

  3. 3

    A teammate used display: flex on a form label and input group, and now the whole form is misaligned because the label is taking up full width. How would you explain the difference between flex and inline-flex here, and what’s the right fix?

5-8 years experience
  1. 1

    We’re building a reusable component library and need a flex-based badge that can be used inline in rich text, block containers, or even inside tables. Should we default to flex or inline-flex? What are the tradeoffs in terms of predictability, accessibility, and layout stability across contexts?

  2. 2

    A legacy component uses inline-flex for a toolbar, but now we’re seeing inconsistent vertical alignment in Safari when nested inside a table cell. What’s the root cause, and how would you design a more robust solution without breaking existing usage?

  3. 3

    We have a responsive layout where inline-flex elements are used for inline action chips. On small screens, they wrap awkwardly and create uneven line heights. How would you redesign this to maintain inline semantics while improving wrap behavior and visual consistency?

8+ years experience
  1. 1

    We’re migrating a legacy UI framework that used inline-block for inline components to CSS flex. Should we standardize on inline-flex across the board, or keep both? What long-term maintenance, accessibility, and cross-browser risks do you weigh when making this architectural decision?

  2. 2

    Our design system has 200+ components using flex or inline-flex. We’re seeing inconsistent behavior in RTL layouts and screen readers. How would you audit and standardize the usage of these display values across teams to ensure predictable, accessible, and scalable layout behavior?

  3. 3

    A major product team wants to use inline-flex for a new inline toolbar that must work inside editable content (like a WYSIWYG editor). What are the fundamental layout and DOM interaction risks here, and how would you design a system-level solution that avoids breaking contenteditable semantics or performance?

Follow-up Questions

  • What happens if you put an inline-flex container inside a paragraph with other text?
  • How would you debug a layout where an inline-flex element seems to be pushing content down unexpectedly?
  • Can you explain why someone might choose inline-flex over flex for a button component?