An official website of the United States government
Official websites use .gov A .gov website belongs to an official government organization in the United States.
Secure .gov websites use HTTPS A lock or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.
Use the display and visibility utility classes to show and hide elements.
Display
The display CSS property specifies the type of rendering box used for an element. In HTML, default display property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet. — MDN
The visibility property can be used to hide an element while leaving the space where it would have been. — MDN
There may be times when you want to hide an element, but still want its text to be read by a screen reader. The ds-u-visibility--screen-reader class will hide the content visually, but provide the content to screen readers.
The ds-u-visibility--hidden-print class uses a print media query to hide content during printing, but otherwise display it normally.
I'm visible to screen readers only and don't take up space
.ds-u-visibility--hidden-print
I'm visible and take up space except when printing
Code snippet
<div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-visibility--visible</code><divclass="utility-example"><spanclass="ds-u-padding--1 ds-u-visibility--visible">
I'm visible and take up space
</span></div></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-visibility--hidden</code><divclass="utility-example"><spanclass="ds-u-padding--1 ds-u-visibility--hidden">
I'm hidden and take up space
</span></div></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-visibility--screen-reader</code><divclass="utility-example"style="min-height: 2px"><spanclass="ds-u-padding--1 ds-u-visibility--screen-reader">
I'm visible to screen readers only and don't take up space
</span></div></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-visibility--hidden-print</code><divclass="utility-example"><spanclass="ds-u-padding--1 ds-u-visibility--hidden-print">
I'm visible and take up space except when printing
</span></div></div></div>
Responsive visibility
Use a breakpoint prefix to show/hide content at specific breakpoints.
A breakpoint prefix is supported on all of the utility classes mentioned above, except for .ds-u-visibility--screen-reader and .ds-u-visibility--hidden-print.