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

What is display: list-item, and when is it used?

Difficulty: 3/10
display property, list semantics, layout

Understanding display: list-item in CSS

display: list-item is a CSS display value that makes an element behave like a list item. This means the element generates a block box and a marker (like a bullet or number) as part of a list.

Key Points
  1. 1

    Elements with display: list-item typically have a marker displayed before their content, similar to <li> elements in HTML lists.

  2. 2

    The marker can be customized using the list-style-type, list-style-position, and list-style-image properties.

  3. 3

    Even standalone elements (like <div> or <p>) can be styled as list items using display: list-item.

  4. 4

    The element behaves as a block box, so width, height, padding, and margins can be applied like a block element.

Example: Using display: list-item

In this example, the <div> and <p> elements act like list items, showing bullets or numbers while keeping their block characteristics.

Best Practices
  1. 1

    Use display: list-item when you want non-<li> elements to appear as list items without changing the HTML structure.

  2. 2

    Combine with list-style properties to customize markers and positions.

  3. 3

    Avoid using display: list-item for complex layouts — use it primarily for list-style presentation.

Scenario Questions

0-2 years experience

  1. 1We need a simple vertical menu where each item shows a bullet, but the container uses flexbox. How would you apply display: list-item to get the bullets while keeping the flex layout?
  2. 2If you set display: list-item on a <div>, what default styles does the browser add, and how does that affect margin collapsing with surrounding elements?

2-5 years experience

  1. 1Your team added display: flex to a <ul> and the list bullets disappeared. Explain why that happened and how you would fix it without removing the flex layout.
  2. 2A list inside a CSS grid cell is creating extra vertical space. The items are using display: list-item. How would you diagnose and resolve the spacing issue?
  3. 3You switched a set of inline tags to display: list-item to keep the markers, but it breaks on Safari. What could be causing the Safari issue and how would you address it?

5-8 years experience

  1. 1Our notification component needs default bullets for some items and custom icons for others, while still behaving like list items for screen readers. How would you structure the CSS, including display: list-item, to support both cases without duplicating styles?
  2. 2A large legacy codebase misuses display: list-item on many non‑semantic elements for visual styling. What strategy would you propose to refactor this at scale, preserving accessibility and minimizing regression risk?
  3. 3When rendering a virtualized infinite‑scroll list, each item must be a list-item for accessibility, but the container uses CSS Grid for performance. Discuss the trade‑offs and how display: list-item interacts with grid and virtualization.

8+ years experience

  1. 1We are moving to a micro‑frontend architecture and have a shared List component that currently applies display: list-item to a <div> to emulate bullets. What are the long‑term implications for accessibility, theming, and cross‑team consistency, and how would you redesign the component to avoid this misuse?
  2. 2Our roadmap includes deprecating native <ul>/<li> in favor of a component‑driven approach using CSS custom properties. How would you ensure the new components still meet WCAG list semantics, given that display: list-item can be applied to any element?

Follow-up Questions

  • How would you customize the bullet shape or color for a list-item?
  • What accessibility considerations arise when using display: list-item on non‑semantic elements?
  • Could you achieve the same visual effect with a ::before pseudo‑element, and what are the trade‑offs?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.