The display property controls an element’s layout role: block flow, inline flow, flex/grid containers, and hiding behavior.
Common values
block,inline,inline-blockflex,gridnone(removed from layout and accessibility tree)
Pitfall
Using display: none for collapsible UI can hide critical content from assistive tech if state announcements are missing.
Important interview questions and answers
- Q: Block vs inline in one line?
A: Block starts new line and can take width; inline flows within text and ignores width/height. - Q: Why use
inline-block?
A: Inline flow positioning with block-like sizing control. - Q: What does
display:noneimpact besides visuals?
A: It removes the element from layout and accessibility tree.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.