Skip to main content

Utilities

Display

Toggle the display value of an element, responsively and for print, with a single class.

How it works

The display utilities set display and nothing else. They are generated from the Utility API, so every value exists at every breakpoint and for print. This theme keeps Bootstrap's full set; nothing is added or removed here. The display-1…display-6 typography classes are a different thing — see Typography.

Notation

Classes are .d-{value} for xs (no breakpoint infix) and .d-{breakpoint}-{value} for sm, md, lg, xl and xxl. Breakpoint classes apply from that width upwards — mobile first, exactly like the grid.

Where value is one of:

  • none
  • inline
  • inline-block
  • block
  • grid
  • inline-grid
  • table
  • table-cell
  • table-row
  • flex
  • inline-flex

So .d-none hides on every viewport, .d-md-block shows as a block from md (768 px) up, and .d-xxl-inline-grid only kicks in at 1400 px and wider. The breakpoint values are listed on Breakpoints.

Examples

d-inline
d-inline
HTML
<div class="d-inline p-2 text-bg-navy">d-inline</div>
<div class="d-inline p-2 text-bg-dark">d-inline</div>
d-block d-block
HTML
<span class="d-block p-2 text-bg-navy">d-block</span>
<span class="d-block p-2 text-bg-dark">d-block</span>

Hiding elements

To hide something on one range of screens, combine a .d-*-none class with a .d-*-{value} class. There is no "hidden only on md" class — you build it from two.

Screen sizeClass
Hidden on all.d-none
Hidden only on xs.d-none .d-sm-block
Hidden only on sm.d-sm-none .d-md-block
Hidden only on md.d-md-none .d-lg-block
Hidden only on lg.d-lg-none .d-xl-block
Hidden only on xl.d-xl-none .d-xxl-block
Hidden only on xxl.d-xxl-none
Visible on all.d-block
Visible only on xs.d-block .d-sm-none
Visible only on sm.d-none .d-sm-block .d-md-none
Visible only on md.d-none .d-md-block .d-lg-none
Visible only on lg.d-none .d-lg-block .d-xl-none
Visible only on xl.d-none .d-xl-block .d-xxl-none
Visible only on xxl.d-none .d-xxl-block
Hide on lg and wider screens — the undercard.
Hide on screens smaller than lg — the main event.
HTML
<div class="d-lg-none">Hide on lg and wider screens — the undercard.</div>
<div class="d-none d-lg-block">Hide on screens smaller than lg — the main event.</div>
.d-none removes the element from the accessibility tree too. If it should stay readable to a screen reader, use .visually-hidden instead. If it should keep its space on the page, use .invisible.

Display in print

The same values exist with a print infix. They apply inside @media print only, so pair them with a screen class when you want different behaviour on paper.

  • .d-print-none
  • .d-print-inline
  • .d-print-inline-block
  • .d-print-block
  • .d-print-grid
  • .d-print-inline-grid
  • .d-print-table
  • .d-print-table-row
  • .d-print-table-cell
  • .d-print-flex
  • .d-print-inline-flex
Screen only (hide on print) — the ticket-booking buttons.
Print only (hide on screen) — the venue address.
Hide up to large on screen, but always show on print.
HTML
<div class="d-print-none">Screen only (hide on print) — the ticket-booking buttons.</div>
<div class="d-none d-print-block">Print only (hide on screen) — the venue address.</div>
<div class="d-none d-lg-block d-print-block">Hide up to large on screen, but always show on print.</div>

CSS

The classes are generated from the "display" entry of the utilities map with responsive: true and print: true. Override or extend them through the Utility API.

"display": (
  responsive: true,
  print: true,
  property: display,
  class: d,
  values: inline inline-block block grid inline-grid table table-row table-cell flex inline-flex none
),