Questions
24 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?
24 / 49

What happens to child elements when their parent has display: none?

Effect of display: none on Child Elements in CSS

When a parent element has display: none, the parent and all of its child elements are completely removed from the layout and rendering flow. They occupy no space and are not visible or interactive.

Key Points
  1. 1

    Child elements are hidden along with the parent; their visibility cannot be toggled independently while the parent is display: none.

  2. 2

    The entire subtree of elements under the parent is ignored by the browser for layout, painting, and events.

  3. 3

    CSS applied to child elements has no visual effect while the parent is display: none.

  4. 4

    Elements removed by display: none are also inaccessible to assistive technologies like screen readers.

Example: Parent with display: none

In this example, the <p> and <span> inside the hidden <div> are completely removed from the layout. Only the paragraph outside the hidden parent is visible and takes up space.

Best Practices
  1. 1

    Use display: none to completely remove elements when they should not occupy space or participate in layout.

  2. 2

    Do not rely on child elements being visible or interactive while the parent is display: none.

  3. 3

    For temporarily hiding content while preserving layout space, use visibility: hidden instead.

Difficulty: 2/10
Topics: layout, rendering, accessibility

Scenario Questions

0-2 years experience
  1. 1

    You have a modal overlay that starts with display: none. What happens to the button inside that overlay before the modal opens?

  2. 2

    If you set display: none on a <section> containing several <p> tags, how does that affect the page layout and the rendering of those paragraphs?

  3. 3

    When you toggle a class that applies display: none to a container, what happens to any event listeners attached to its child elements?

2-5 years experience
  1. 1

    During debugging you see a dropdown not appearing even though JavaScript adds an open class. The parent has display: none under a media query. Explain why the children stay hidden and how you'd fix it.

  2. 2

    Your team hides a loading spinner by setting display: none on its wrapper after data loads. Compare the performance of this approach to removing the element from the DOM.

  3. 3

    A hidden form field inside a container with display: none is still being submitted. Is that expected, and why?

5-8 years experience
  1. 1

    Designing a component library that supports SSR, discuss the trade‑offs of using display: none to hide components versus conditionally rendering them, especially for initial paint and bundle size.

  2. 2

    In a large SPA many sections are toggled with display: none and you notice slower reflows over time. Explain the browser mechanisms behind this and propose a mitigation strategy.

  3. 3

    Accessibility guidelines advise against display: none for content that should be read by screen readers. How would you architect a solution that hides UI visually while keeping it accessible?

8+ years experience
  1. 1

    Your organization is migrating a legacy monolith UI to micro‑frontends. Some legacy components rely on display: none to hide large DOM trees that remain in the page. Evaluate the long‑term maintenance and performance risks, and outline a migration plan to refactor these patterns across teams.

  2. 2

    As the design system owner, you need a policy for hiding content across hundreds of apps. Discuss how you would standardize the use of display: none versus alternatives like visibility:hidden, aria-hidden, or portal rendering to balance SEO, accessibility, and runtime performance at scale.

Follow-up Questions

  • Can you explain how the rendering pipeline handles elements with display:none?
  • What would change if you used visibility:hidden instead?
  • How does display:none affect screen‑reader visibility and SEO?