CSS <display-box> Data Type
The <display-box> data type is the display keyword none or contents, which decides whether an element generates a box at all.
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
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
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.
Desktop





Tablets & Mobile





