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 Mode | Starts New Line? | Respects Width/Height? | Vertical Margin/Padding? | Typical HTML Elements |
|---|---|---|---|---|
| block | YES (100% line) | YES | YES | <div>, <p>, <h1>, <section> |
| inline | NO (Flows in text) | NO (IGNORED!) | NO (Top/bottom ignored) | <span>, <a>, <strong>, <em> |
| inline-block | NO (Sits side-by-side) | YES (Fully custom) | YES (Pushes elements) | <button>, <input>, <img> |
| none | Removed from flow | No layout space | Zero footprint | Modal 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: noneEvicted from layout. Takes zero space on screen. Screen readers ignore it. Click events cannot trigger.
visibility: hiddenGhost on the wall. Invisible, but still occupies its exact width and height in the layout flow!
opacity: 0100% 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
Continue to Positioning8. Positioning
static, relative, absolute, fixed, sticky, and z-index stacking contexts.