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

What happens when you set display: none on an element?

Understanding display: none in CSS

When you set display: none on an element, it is completely removed from the document’s layout flow. This means it does not take up any space on the page, and other elements behave as if it doesn’t exist.

Key Characteristics of `display: none`
  1. 1

    The element becomes invisible and occupies no space in the layout.

  2. 2

    It is not accessible for user interactions like clicking or hovering.

  3. 3

    Child elements of the hidden element are also not rendered.

  4. 4

    The element can be made visible again by changing its display property (e.g., display: block or display: inline).

  5. 5

    display: none is different from visibility: hidden, which hides the element but still reserves its layout space.

Example: Using `display: none`

In this example, the second paragraph is not rendered on the page at all. The third paragraph moves up immediately after the first one, as if the hidden element doesn’t exist.

Best Practices
  1. 1

    Use display: none for toggling visibility dynamically with JavaScript (e.g., dropdowns, modals).

  2. 2

    Avoid using display: none to hide content important for accessibility — screen readers won’t detect it.

  3. 3

    If you need the element hidden but still occupying space, use visibility: hidden instead.

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

Scenario Questions

0-2 years experience
  1. 1

    If you set display:none on a button inside a form, what effect does it have on the form's submission behavior?

  2. 2

    How would you hide a modal using CSS while keeping it in the DOM, and what does display:none do in that case?

  3. 3

    When a parent element has display:none, what happens to its child elements in the page layout?

2-5 years experience
  1. 1

    You added a class that toggles display:none on a dropdown, but the menu never appears. Walk me through how you’d debug this.

  2. 2

    Why doesn’t a CSS transition on opacity work when the element is shown/hidden with display:none, and what alternative would you use?

  3. 3

    In a React component you conditionally apply display:none to a section. Why might screen readers still announce its content, and how would you fix it?

5-8 years experience
  1. 1

    Discuss the performance trade‑offs of using display:none on a large list of items versus removing those items from the DOM entirely.

  2. 2

    When building a virtualized list, would you rely on display:none to hide off‑screen rows? Why or why not?

  3. 3

    In a themable UI library, how do you ensure that components using display:none don’t cause unexpected layout reflows on high‑DPI devices?

8+ years experience
  1. 1

    Your team is migrating a legacy codebase that heavily uses display:none for feature flags. Propose a strategy to refactor this for better accessibility and maintainability.

  2. 2

    At scale, how does widespread use of display:none affect the critical rendering path, and what architectural changes would you recommend?

  3. 3

    Compare using display:none versus visibility:hidden in a cross‑team design system, considering SEO, accessibility, and performance trade‑offs.

Follow-up Questions

  • Can you explain how display:none impacts reflow and repaint?
  • What differences would you expect for screen readers when using display:none?
  • How would you verify that an element truly isn’t affecting layout in the browser?