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

What is the difference between display: block and display: inline?

Difference Between display: block and display: inline in CSS

The display property controls how an element is rendered in the document flow. The key difference between display: block and display: inline lies in how they occupy space and interact with other elements.

Main Differences
  1. 1

    display: block — The element starts on a new line and stretches to fill the full available width.

  2. 2

    display: inline — The element stays within a line and only takes up as much width as its content.

  3. 3

    Block elements can have width, height, margin, and padding applied in all directions.

  4. 4

    Inline elements ignore top and bottom margin or padding (they only affect left and right).

  5. 5

    Multiple inline elements can appear next to each other in the same line, but block elements stack vertically.

Example: Block vs Inline Elements

In this example, the block element appears on its own line and takes the full width, while the inline elements sit next to each other within the same line.

Key Points
  1. 1

    block elements form the main structure of the page (e.g., <div>, <section>, <p>).

  2. 2

    inline elements are best for text-level content (e.g., <span>, <a>, <strong>).

  3. 3

    You can change an element’s display type using CSS to modify layout behavior.

  4. 4

    Combining inline and block properly ensures clean, predictable page layouts.

Difficulty: 2/10
Topics: display property, layout behavior, CSS box model

Scenario Questions

0-2 years experience
  1. 1

    If you have a <span> element and you set display: block, how does its rendering change compared to the default?

  2. 2

    You need a navigation menu where each item should sit on its own line. Would you use display: block or display: inline on the <li> elements, and why?

  3. 3

    What happens to the width and height of an element when you switch from display: inline to display: block?

2-5 years experience
  1. 1

    We have a component that uses display: inline for icons inside a button, but the icons sometimes overflow the button height. How would you debug and decide whether to change the display value?

  2. 2

    During a refactor, a developer changed a <div> from display: block to display: inline to reduce markup, and the layout broke. Explain what likely broke and how you'd fix it.

  3. 3

    When building a responsive card grid, you consider using display: inline-block versus display: block with floats. Discuss the trade‑offs.

5-8 years experience
  1. 1

    Our design system includes a utility class .inline that sets display: inline. A new feature requires these elements sometimes need width/height. How would you evolve the utility to support both use‑cases without breaking existing pages?

  2. 2

    We have a large legacy codebase where many components rely on display: block for layout, but we want to migrate to a flexbox‑based system. What challenges do display differences introduce, and how would you plan the migration to avoid regressions?

  3. 3

    Explain how display: block vs inline affects reflow and paint performance when rendering a page with thousands of items, and what you would consider when optimizing.

8+ years experience
  1. 1

    Our company is consolidating multiple UI libraries into a single design system. Some libraries use display: inline for form controls, others use block. How would you create a cross‑team strategy to standardize display behavior while preserving backward compatibility?

  2. 2

    When moving from a monolithic CSS architecture to a CSS‑in‑JS solution, you need to decide how to represent layout primitives like block vs inline. What architectural considerations would guide your decision, and how would you ensure consistent behavior across all products?

  3. 3

    If you were tasked with auditing the global stylesheet for accessibility and performance, how would misuse of display: inline versus block impact screen readers and layout stability, and what remediation plan would you propose?

Follow-up Questions

  • What happens to margin collapsing when you switch between block and inline?
  • Can you combine `display: inline` with other layout properties like flex or grid?
  • How does `display: inline-block` fit between the two?