These keywords define whether an element generates display boxes at all.

Syntax

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 concerns section below for more details.
none
Turns off the display of an element so that it has no effect on layout (the document is rendered as though the element did not exist). All descendant elements also have their display turned off.
To have an element take up the space that it would normally take, but without actually rendering anything, use the visibility property instead.

Formal syntax

Syntax not found in DB!

Examples

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.

display: none

HTML

<p>Visible text</p>
<p class="secret">Invisible text</p>

CSS

p.secret {
  display: none;
}

Result

display: contents

In this example the outer <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.

HTML

<div class="outer">
  <div>Inner div.</div>
</div>

CSS

.outer {
  border: 2px solid red;
  width: 300px;
  display: contents;
}

.outer > div {
  border: 1px solid green;
}

Result

Browser compatibility

Support of contents

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome Full support 65
Full support 65
No support 58 — 65
Disabled
Disabled From version 58 until version 65 (exclusive): this feature is behind the Enable experimental Web Platform features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox Full support 37
Full support 37
No support 36 — 53
Disabled
Disabled From version 36 until version 53 (exclusive): this feature is behind the layout.css.display-contents.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 52Safari Full support 11.1WebView Android Full support 65Chrome Android Full support 65Edge Mobile No support NoFirefox Android Full support 57Opera Android Full support 52Safari iOS Full support 11.1Samsung Internet Android No support No
Specific behavior of unusual elements when display: contents is applied to them
Experimental
Chrome ? Edge No support NoFirefox Full support 59IE No support NoOpera No support NoSafari No support NoWebView Android ? Chrome Android ? Edge Mobile No support NoFirefox Android Full support 59Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Contributors to this page: mdnwebdocs-bot, ExE-Boss, chrisdavidmills, rachelandrew
Last updated by: mdnwebdocs-bot,