Favorites

CSS <display-box> Data Type

<display-box>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <display-box> data type is the display keyword none or contents, which decides whether an element generates a box at all.

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 <display-box> CSS data type represents the values of the display property that decide whether an element generates a box at all. It has two keywords: none and contents. Most display values describe what kind of box an element creates (block, inline, flex, grid and so on), but these two describe the absence of the element's own box.

display: none removes the element and all of its descendants from the layout entirely. Nothing is drawn, no space is reserved, and the content is also hidden from assistive technologies such as screen readers. It is the usual way to hide something completely, for example a closed menu or a tab panel that is not selected. If you only want to make an element invisible while keeping its space, use visibility: hidden instead.

display: contents removes only the element's own box, while its children and text are still displayed as if they were direct children of the element's parent. This is useful when an extra wrapper element gets in the way of a grid or flex layout: setting the wrapper to contents lets its children become grid or flex items directly. Because the box is gone, properties such as backgrounds, borders, padding and margins set on that element no longer have any visible effect. Take care when using it on interactive or semantic elements such as buttons, links, lists and headings, as some browsers have historically removed them from the accessibility tree.

Examples:

/* Hide an element completely */
.menu[hidden],
.is-collapsed {
  display: none;
}

/* Let the children of a wrapper join the parent grid */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.grid .group {
  display: contents;
}

Together, the two <display-box> keywords give you control over whether an element appears in the layout and whether its wrapper takes part in it.

Interactive Demo

A
B1 B2
C
The pink dashed div wraps B1 and B2.
Demo Code
HTML Code
<div class="demo-flex">
	<span>A</span>
	<div class="demo-element">
		<span>B1</span>
		<span>B2</span>
	</div>
	<span>C</span>
</div>
<small class="demo-note">The pink dashed div wraps B1 and B2.</small>
CSS Code
.demo-flex {
	display: flex;
	gap: 6px;
	width: 300px;
	padding: 6px;
	box-sizing: border-box;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
}
.demo-flex span {
	display: block;
	padding: 8px 10px;
	background: #4361ee;
	color: #fff;
	font-size: 14px;
}
.demo-note {
	display: block;
	margin: 6px 0 0;
	font-size: 12px;
	color: #666;
}
.demo-element {
	padding: 6px;
	border: 2px dashed #f72585;
	background: #ffe5f1;
	display: block;
}

Syntax

<display-box> = contents | none

Values

  • contentsThe element does not produce a box of its own, but its children and pseudo-elements are still generated and laid out as if they belonged to the element's parent.
  • noneThe element and all of its descendants generate no boxes. It is removed from the layout and is not displayed.

Example

<div class="wrap">
<h1>CSS &lt;display-box&gt; examples</h1>

<h2>wrapper with display: block (default)</h2>
<div class="grid">
<div class="item">A</div>
<div class="group">
<div class="item">B</div>
<div class="item">C</div>
</div>
<div class="item">D</div>
</div>

<h2>wrapper with display: contents</h2>
<div class="grid contents">
<div class="item">A</div>
<div class="group">
<div class="item">B</div>
<div class="item">C</div>
</div>
<div class="item">D</div>
</div>

<h2>wrapper with display: none</h2>
<div class="grid none">
<div class="item">A</div>
<div class="group">
<div class="item">B</div>
<div class="item">C</div>
</div>
<div class="item">D</div>
</div>
</div>
/* Compares a normal wrapper, display: contents and display: none */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 12px;
}

h2 {
  font-size: 14px;
  color: #486581;
  margin: 18px 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e1e8f0;
}

.group {
  border: 2px dashed #f97316;
  padding: 6px;
  border-radius: 8px;
  background: #fff7ed;
}

.item {
  padding: 14px;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.contents .group { display: contents; }
.none .group { display: none; }
Open in editor

Browser Support

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

This data type 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.