Skip to content
Back to Concepts
CSS UniverseTrack 2: GeometryDisplay Modes
1st Year CS Foundation ยท Core Track 2Core Concept 07

CSS Display Modes

How elements sit on a page. The difference between giant heavy bricks (block), flowing river words (inline), versatile hybrid chips (inline-block), and the invisible cloak (none).

1. The Display Modes Matrix

Block vs Inline vs Inline-Block vs None

Display ModeStarts New Line?Respects Width/Height?Vertical Margin/Padding?Typical HTML Elements
blockYES (100% line)YESYES<div>, <p>, <h1>, <section>
inlineNO (Flows in text)NO (IGNORED!)NO (Top/bottom ignored)<span>, <a>, <strong>, <em>
inline-blockNO (Sits side-by-side)YES (Fully custom)YES (Pushes elements)<button>, <input>, <img>
noneRemoved from flowNo layout spaceZero footprintModal dialogs, hidden tabs
2. Live Display Mode Sandbox

Switch Display on Sibling Boxes

display:
Before text...
Box 1 (inline-block)
Box 2 (inline-block)
...after text continues seamlessly here.
Notice: Boxes sit side-by-side like words, but respect your exact width and height!
3. The Invisible Triad (Interview Classic)

`display: none` vs `visibility: hidden` vs `opacity: 0`

display: none

Evicted from layout. Takes zero space on screen. Screen readers ignore it. Click events cannot trigger.

visibility: hidden

Ghost on the wall. Invisible, but still occupies its exact width and height in the layout flow!

opacity: 0

100% Transparent. Takes space AND user can still accidentally click buttons inside it! Animatable with transitions.

4. Display Modes Playground

Full Display Modes Lab

Interactive Lab

Display Modes

Switch between inline, block, inline-block, flex, grid, and flow-root to see layout behavior.

Display: block

Try these

  • Switch between block, inline, inline-block to see flow differences.
  • Try flex and grid, adjust gap, and resize to see wrapping/flow-root.
  • Use flow-root to contain floats if needed.
Alpha
Beta
Gamma
Delta
CSS
.display-demo {
  display: block;
  gap: 12px;
}
HTML
<div class="display-demo">
  <div>Alpha</div>
  <div>Beta</div>
  <div>Gamma</div>
  <div>Delta</div>
</div>
Next in Track 2

8. Positioning

static, relative, absolute, fixed, sticky, and z-index stacking contexts.

Continue to Positioning