CSS display Property

Theory & Explanation

The display property in CSS is the foundation of layout and rendering. It controls how elements are visually formatted, how they participate in the document flow, and how they interact with other elements. Mastery of display is essential for building any web layout, from simple pages to complex applications.

Other values: flex (for flexible box layouts), grid (for grid layouts), table (for table-like layouts), and more. These advanced values enable powerful, responsive designs.

How display Affects Layout

Accessibility & Best Practices

Code Examples

/* Block-level */
.block-demo .demo-box {
  display: block;
}

/* Inline-level */
.inline-demo .demo-box {
  display: inline;
}

/* Inline-block */
.inline-block-demo .demo-box {
  display: inline-block;
}

/* None */
.none-demo .demo-box {
  display: none;
}

Live Demos & Interactive Examples

block
Block 1
Block 2
inline
Inline 1
Inline 2
inline-block
Inline-block 1
Inline-block 2
none
You can't see me!
Mixed Example
Block Inline Inline-block

Block starts on a new line, inline flows, inline-block is inline but sized.

Try toggling the display type of each demo using the buttons, or inspect the elements to see how display changes their layout and visibility.

← Back to Home