files/en-us/web/css/reference/values/display-box/index.md
These keywords define whether an element generates display boxes at all.
Valid <display-box> values:
contents
: These elements don't produce a specific box by themselves. They are replaced by their pseudo-box and their child boxes. Please note that the CSS Display Level 3 spec defines how the contents value should affect "unusual elements" — elements that aren't rendered purely by CSS box concepts such as replaced elements. See Appendix B: Effects of display: contents on Unusual Elements for more details.
Due to a bug in browsers this will currently remove the element from the accessibility tree — screen readers will not look at what's inside. See the Accessibility section below for more details.
none
Current implementations in most browsers will remove from the accessibility tree any element with a display value of contents. This will cause the element — and in some browser versions, its descendant elements — to no longer be announced by screen reading technology. This is incorrect behavior according to the CSSWG specification.
{{csssyntax}}
In this first example, the paragraph with a class of secret is set to display: none; the box and any content is now not rendered.
<p>Visible text</p>
<p class="secret">Invisible text</p>
p.secret {
display: none;
}
{{EmbedLiveSample("display_none", "100%", 60)}}
In this example the outer {{htmlelement("div")}} has a 2-pixel red border and a width of 300px. However it also has display: contents specified therefore this <div> will not be rendered, the border and width will no longer apply, and the child element will be displayed as if the parent had never existed.
<div class="outer">
<div>Inner div.</div>
</div>
.outer {
border: 2px solid red;
width: 300px;
display: contents;
}
.outer > div {
border: 1px solid green;
}
{{EmbedLiveSample("display_contents", 300, 60)}}
{{Specifications}}
{{Compat}}
{{CSSxRef("display")}}
More accessible markup with display: contents by Hidde de Vries (2018)