Questions
37 of 49
1What is the display property in CSS used for?
2What is the default display value for <div>, <span>, <p>, and <a> tags?
3What is the difference between display: block and display: inline?
4How does display: inline-block behave?
5What happens when you set display: none on an element?
6How is display: none different from visibility: hidden?
7Can display: none affect layout reflow or accessibility?
8What’s the effect of display: block on inline elements like <span>?
9What’s the difference between display: table and actual HTML <table> elements?
10How do replaced elements (like <img> or <input>) behave with different display values?
11How is display: flex different from display: block?
12What is the difference between display: grid and display: flex?
13What happens if you apply display: inline-flex to a container?
14What is the difference between display: contents and display: none?
15What is display: list-item, and when is it used?
16How does display: run-in work, and why is it rarely used?
17What’s the difference between display: inline-grid and display: grid?
18How can you make an element behave like both inline and block elements?
19What happens to child elements when the parent has display: contents?
20How does the display property affect box model calculations?
21How can you change a block-level element to behave like an inline element without changing its tag?
22How do you center elements using display: flex or display: grid?
23How can you hide elements but keep their layout space?
24What happens to child elements when their parent has display: none?
25How can display: contents help improve semantic markup but hurt accessibility?
26What happens if you set display: flex on the <body> tag?
27How do you use display to build responsive layouts?
28What is the difference between using display and position to arrange elements?
29How can you visually hide an element but keep it accessible for screen readers?
30How does display affect stacking and z-index behavior?
31Does display: none remove an element from the DOM?
32Can an element with display: none trigger CSS transitions or animations?
33How does display interact with CSS pseudo-elements (::before, ::after)?
34What is the difference between visibility: collapse and display: none in table elements?
35How can you make text and icons align properly using display values?
36How do block formatting contexts relate to display types?
37What happens if you apply display: table to a flex container?
38How does display behave differently for replaced vs. non-replaced elements?
39Can display be animated using CSS transitions?
40How does display affect the accessibility tree and ARIA roles?
41How can you make a <li> element appear horizontally instead of vertically?
42How do you create a two-column layout without using float or position, using only display?
43How do you make an image and text sit side by side neatly?
44How would you make a navigation menu horizontally aligned using display?
45How can you make all elements behave as border-box and block-level by default?
46How would you use display: flex to make a footer stick to the bottom?
47How can display: grid simplify responsive design compared to floats?
48When would you prefer display: inline-flex over display: flex?
49How can you use display: contents to remove extra wrappers in semantic HTML structures? How can incorrect use of display lead to accessibility or SEO problems?
37 / 49

What happens if you apply display: table to a flex container?

Applying display: table to a Flex Container in CSS

When you change a flex container’s display to table, the element stops behaving as a flex container. Flexbox properties like flex-direction, justify-content, and align-items no longer apply, because the element is now treated as a CSS table container.

Key Effects
  1. 1

    The container loses all flex layout behavior; its children are laid out according to table rules.

  2. 2

    Children behave as table rows or table cells depending on their own display values (table-row, table-cell).

  3. 3

    Margins, padding, and alignment work differently compared to flex layout, and vertical/horizontal centering is affected.

  4. 4

    Any BFC behavior created by display: flex is replaced by table layout rules, though the container still participates in normal block flow.

Example: Flex to Table

In this example, the container behaves like a table, and each child element becomes a table cell. Flex properties no longer affect layout, and table-specific rules control the sizing and alignment of children.

Best Practices
  1. 1

    Do not mix flex properties with display: table; choose one layout model for consistency.

  2. 2

    Use display: table only when table-like layout behavior is desired, such as equal-height columns or row/column alignment.

  3. 3

    For responsive designs, flex or grid is usually more flexible than table display.

  4. 4

    Remember that changing display types can affect margin collapsing, BFC behavior, and accessibility.

Difficulty: 5/10
Topics: display property interaction, layout models, CSS specificity

Scenario Questions

0-2 years experience
  1. 1

    You have a component styled with display:flex and you accidentally add display:table. What will the browser render, and how will the children behave?

  2. 2

    If you need the children to stay in a flex layout, what change would you make to the CSS?

2-5 years experience
  1. 1

    During a code review you notice a modal component using both display:flex and display:table. The layout is broken on Chrome. Walk me through how you'd debug this and decide which display to keep.

  2. 2

    Explain why justify-content: center stopped working after a teammate added display: table to the container. What trade‑offs are you considering when fixing it?

5-8 years experience
  1. 1

    We're building a reusable card component that sometimes needs to act like a table for legacy integration but otherwise should be a flex container. How would you architect the CSS to avoid conflicts when display: table is applied?

  2. 2

    Discuss the performance and rendering implications of toggling between flex and table layouts on a large list of items. How would you mitigate any issues?

8+ years experience
  1. 1

    Our design system currently mixes utility classes that set display:flex and others that set display:table. Teams report unexpected layout bugs. As a staff engineer, how would you restructure the CSS architecture to prevent such conflicts across the organization?

  2. 2

    We need to migrate a legacy admin dashboard built with table layouts to a modern flex‑based UI without breaking existing pages. Outline a migration strategy that handles cases where both display values might be present.

Follow-up Questions

  • What CSS rule determines which `display` value takes precedence?
  • How would you test that the flex properties are no longer applied after the change?
  • Can you think of any browsers where the behavior differs or has known bugs?