Favorites

CSS display Property

display
CSS PropertyThis property is supported by all modern browsers.
Updated 22nd November 2026

The display property sets how an element is displayed: its outer type, such as block or inline, and its inner layout, such as flex or grid, or none to hide it.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The CSS property display defines how an element is presented in the document’s layout: it determines what kind of box the element generates, whether that box participates in the normal flow, and how that element interacts with its siblings and children. At a conceptual level, display is the switch that selects a layout model for an element — which in turn governs how its content is laid out, whether it establishes a new formatting context, and whether anonymous boxes or wrappers are created around children. Because it controls the element’s outer box type and how children are rendered, changing display often has broader visual and structural consequences than changing many other properties.

The behavior of an element set by display also intersects with other layout mechanisms: for example, it combines with the element’s position to determine whether it participates in normal flow or becomes positioned independently, and it affects how floats created with float interact with neighboring boxes. When an element establishes a new formatting context, it can isolate or change how children are laid out relative to outside elements; this is why altering display can change not only the element itself but also cascade into repositioning and rewrapping of nearby content.

Practical layout and rendering considerations also flow from the choice of display. It influences overflow handling and clipping behavior, so it works closely with overflow when content exceeds available space; it also affects visibility, painting order and hit testing alongside visibility and stacking properties like z-index. Because changing an element’s display type can trigger reflow and repaints, it has performance implications for dynamic updates and animations; developers often choose display values that minimize layout churn when toggling UI state or animating pieces of the page.

For authors, think of display as the foundational choice that determines an element’s role in the document’s box tree. Selecting the appropriate display behavior leads to more predictable composition of layout, clearer interaction with other CSS mechanisms, and fewer surprises when combining styles. When restructuring or debugging layout issues, inspecting the element’s computed display is usually one of the first steps to understanding why content wraps, overlaps, or behaves differently than expected.

Definition

Initial value
inline
Applies to
All elements
Inherited
No
Computed value
Specified value, except for floats, root elements and positioned elements
Animatable
No
JavaScript syntax
object.style.display

Interactive Demo

Text before
OneTwoThree
text after.
Demo Code
HTML Code
<div class="demo-wrap">Text before
	<div class="demo-element"><span>One</span><span>Two</span><span>Three</span></div>
	text after.</div>
CSS Code
.demo-wrap {
	width: 300px;
	font-size: 14px;
	color: #444;
}
.demo-element span {
	display: block;
	padding: 6px 10px;
	background: #4361ee;
	color: #fff;
}
.demo-element {
	gap: 6px;
	padding: 8px;
	background: #ffe5f1;
	border: 2px solid #f72585;
	display: block;
}

Syntax

display: [ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy>  /* e.g. block | inline | inline-block | flex | inline-flex | grid | inline-grid | flow-root | list-item | table | contents | none */

Values

  • inlineThe element generates one or more inline element boxes.
  • blockThe element generates a block element box.
  • inline-blockThe element generates a block element box that will be flowed with surrounding content as if it were a single inline box (behaving much like a replaced element would)
  • list-itemThe element generates a block box for the content and a separate list-item inline box.
  • run-inEither one or more block-level, block container boxes, or one or more inline-level, inline container boxes, depending on context
  • tableSee the Tables module
  • inline-tableSee the Tables module
  • table-row-groupSee the Tables module
  • table-header-groupSee the Tables module
  • table-footer-groupSee the Tables module
  • table-rowSee the Tables module
  • table-column-groupSee the Tables module
  • table-columnSee the Tables module
  • table-cellSee the Tables module
  • table-captionSee the Tables module
  • rubySee the Ruby module
  • ruby-baseSee the Ruby module
  • ruby-textSee the Ruby module
  • ruby-base-groupSee the Ruby module
  • ruby-text-groupSee the Ruby module
  • flexGenerates a block element for laying out content in the flexbox model. This is a flexbox model value in CSS3.
  • inline-flexGenerates an inline element for laying out content in the flexbox model. This is a flexbox model value in CSS3.
  • noneTurns off the display of an element (it has no effect on layout); all descendant elements also have their display turned off. The document is rendered as though the element did not exist.
  • gridThe element generates a block-level grid container box.
  • inline-gridThe element generates an inline-level grid container box.
  • flow-rootThe element generates a block box that establishes a new block formatting context, containing its floats.
  • contentsThe element itself does not generate a box; its children are laid out as if they were children of its parent.

Example

<div class='wrapper'>
<h2>CSS display examples</h2>
<div class='examples'>
<div class='box block'>Block element (div) - display: block</div>
<span class='box inline'>Inline element (span) - display: inline</span>
<div class='box inline-block'>Inline-block element - display: inline-block</div>
<div class='flex-container'>
<div class='flex-item'>Flex 1</div>
<div class='flex-item'>Flex 2</div>
<div class='flex-item'>Flex 3</div>
</div>
<div class='grid-container'>
<div class='grid-item'>1</div>
<div class='grid-item'>2</div>
<div class='grid-item'>3</div>
<div class='grid-item'>4</div>
</div>
<div class='box none'>Hidden element - display: none</div>
</div>
</div>
/* Basic page */
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  padding: 20px;
  background: #f7f9fc;
  color: #111827;
}

.wrapper {
  max-width: 800px;
  margin: 0 auto;
}

.examples {
  display: grid;
  gap: 12px;
}

.box {
  padding: 12px 16px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e6e9ef;
}

.block {
  display: block;
}

.inline {
  display: inline;
  background: #eef2ff;
  margin-left: 8px;
}

.inline-block {
  display: inline-block;
  width: 180px;
  vertical-align: middle;
}

.flex-container {
  display: flex;
  gap: 10px;
}

.flex-item {
  flex: 1 1 0;
  padding: 12px;
  background: #fff7ed;
  border: 1px solid #fde3c5;
  text-align: center;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.grid-item {
  padding: 12px;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  text-align: center;
}

.none {
  display: none;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS display property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.