CSS — Lesson 8

Display Property

Controlling how elements are displayed and laid out.

By Majed Qandeel · Jul 26, 2026 · Lesson 8 of 15

Display Property

The display property determines how an element is rendered in the page layout.

Common Display Values

/* Block: full width, new line */ .block-element { display: block; } /* Inline: flows with text */ .inline-element { display: inline; } /* Inline-block: inline flow + respects width/height */ .inline-block-element { display: inline-block; } /* None: removes from layout */ .hidden { display: none; }

Block vs Inline vs Inline-Block

Propertyblockinlineinline-block
Width/HeightRespectsIgnoresRespects
Margin/PaddingAll sidesHorizontal onlyAll sides
New LineYesNoNo

display: none vs visibility: hidden

.removed { display: none; } /* Removes from layout */ .invisible { visibility: hidden; } /* Hides but keeps space */
Tip: Use inline-block when you need inline flow with width/height support. For modern layouts, prefer Flexbox or Grid.

Practice what you learned in the Deoit Editor — a free, browser-based code editor.

Open Editor →