Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

Bootstrap Display and Visibility: How to Show or Hide Elements

Use Bootstrap’s responsive display utilities to show or hide elements at specific viewport widths, and choose the right helper for layout space and screen-reader access.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Bootstrap 5, use responsive .d-* display utilities to show or hide elements at specific viewport widths. Choose .d-none to remove an element from layout; choose .invisible to hide it while preserving its space. For content that should stay available to screen readers, use .visually-hidden or, for a keyboard-revealed skip link, .visually-hidden-focusable.

Choose the right Bootstrap utility

Decide first whether the element should take up space and whether assistive technology should receive its content. These classes are not interchangeable.

Utility Effect on layout Assistive technology Use it for
.d-none or .d-{breakpoint}-none display: none; the element does not participate in layout while hidden Content is not exposed while hidden Removing an element at all or selected viewport sizes
.invisible Preserves the element’s display and layout space Bootstrap documents it as hidden from assistive technology too Hiding an element from everyone while leaving a blank space
.visually-hidden Visually hides the content Content remains available to assistive technologies Screen-reader context that should not appear visually
.visually-hidden-focusable Visually hidden until focused Available to assistive technologies and revealed on focus Skip links and similar keyboard-discoverable controls

Bootstrap’s v5.3 visibility documentation notes that .invisible does not modify display: invisible elements still take up space. See the Bootstrap v5.3 Visibility documentation for its behavior and the Display utilities documentation for display classes.

Hide an element at every viewport size

Add .d-none to the element:

<div class="d-none">Hidden at all breakpoints</div>

Use this when the element should not be displayed or take up layout space at any viewport width. To hide something only at selected widths, combine responsive classes as described below.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Show or hide an element at a breakpoint

Bootstrap’s responsive display utilities use minimum-width breakpoints: a class applies at its named breakpoint and wider. In Bootstrap 5.3, the breakpoint names are sm, md, lg, xl and xxl. Pair .d-none with the display mode you want when the element becomes visible.

<div class="d-none d-md-block">Hidden below md; block at md and wider</div>

Here .d-none hides the element by default, and .d-md-block displays it as a block from md upward. Choose the display mode that fits the element: Bootstrap documents values including block, inline, inline-block, flex, grid and table.

Show only within a range

To display an element from md up to, but not including, xl, combine classes:

<div class="d-none d-md-block d-xl-none">
  Shown from md until the xl breakpoint
</div>

The md rule turns display on at that minimum width; .d-xl-none hides the element again at xl and wider. This works because the breakpoint utilities are minimum-width rules, not exclusive ranges.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Change display mode responsively

Use the same pattern to change an element’s display mode at a breakpoint. For example, a flex layout can be turned off at larger widths:

<div class="d-flex d-lg-block">Flex below lg; block at lg and wider</div>

Check the Bootstrap 5.3 display utility list for the supported values and responsive forms.

Hide an element but preserve its space

Use .invisible when the element should not be seen but its place in the layout should remain:

<div class="invisible">Hidden but still occupies layout space</div>

Do not choose this as a screen-reader-only technique. Bootstrap documents that .invisible hides content from assistive technology as well as sighted visitors. If the content must remain available to screen readers, use a visually hidden helper instead.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hide content visually but keep it accessible

Bootstrap’s visually hidden helpers are for content that should remain available to assistive technologies. Use .visually-hidden for supplemental context that is not shown visually:

<span class="visually-hidden">Additional context for screen-reader users</span>

For a skip link, use .visually-hidden-focusable so keyboard focus reveals it:

<a class="visually-hidden-focusable" href="#content">Skip to main content</a>

These helper names are documented in the Bootstrap v5.1 Visually hidden helpers documentation. Confirm the version installed in your project and use the matching documentation.

Set different display behavior for print

Bootstrap 5.3 provides print display utilities such as .d-print-none and .d-print-block. Combine a print utility with screen display classes when content should appear differently on screen and on paper. For example, this element is shown as a block on screen and omitted from print:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<div class="d-block d-print-none">Screen-only content</div>

See the Bootstrap display documentation for the other documented .d-print-* forms.

Check your Bootstrap version before copying class names

Responsive utility names changed across major Bootstrap versions. The examples above use Bootstrap 5 syntax; older projects may not recognize those classes.

  • Bootstrap 5.3: uses responsive .d-{breakpoint}-{value} utilities, including sm, md, lg, xl and xxl, as well as .d-print-* classes. See the v5.3 display documentation.
  • Bootstrap 4.6: documents the same general responsive .d-{breakpoint}-{value} pattern through xl, including print utilities. See Bootstrap 4.6 Display.
  • Bootstrap 3: uses older patterns such as .hidden, .show, .hidden-*, .visible-*, and .sr-only. Some .visible-* classes were marked deprecated in that version. Consult the Bootstrap CSS documentation rather than copying Bootstrap 5 class names into a Bootstrap 3 project.

Bootstrap’s v4 migration guide describes historical changes to responsive visibility utilities. For the specific version in your project, use its own documentation: class names and behavior are not guaranteed to carry over between major releases.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot display and visibility utilities

The element stays hidden at a wide viewport

Check the class combination and the loaded Bootstrap version. A class such as .d-lg-none hides the element at lg and wider; it does not mean “hide only on large screens.” To show an element from a breakpoint upward, pair a default hidden state with a display mode, such as .d-none d-md-block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The hidden element leaves an empty gap

That is the expected layout behavior of .invisible. Switch to a .d-none utility if the element should stop taking up layout space while hidden.

A screen reader does not announce the content

Check whether you used .d-none or .invisible. Both hide content from assistive technology while hidden according to the relevant Bootstrap documentation. Use .visually-hidden for content that should stay available, or .visually-hidden-focusable for a keyboard-focusable link that should be revealed on focus.

The utility class appears to have no effect

Verify that the project actually loads the Bootstrap version whose class names you used. Bootstrap 3 legacy visibility classes differ from the Bootstrap 4 and 5 .d-* pattern. Also check whether your own CSS overrides the utility; the Bootstrap documentation for the installed version is the reference for the intended behavior.

Or skip the browser setup

If you need an image or PDF of a page to inspect the result, you can use ScreenshotNeo, a website screenshot API and MCP server for developers. Its API accepts a URL in one GET request and returns an image or PDF. The following cURL example saves a WebP screenshot of a Bootstrap documentation page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://getbootstrap.com/docs/5.3/utilities/display/ -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo can accept cookie or consent banners and remove known consent platforms, newsletter popups and chat widgets before a capture. Bot checks, blank pages, failed loads and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

What does the `d` in Bootstrap’s `.d-none` class mean?

It refers to the CSS `display` property that the utility sets.

Can I use `.invisible` to make text screen-reader-only?

No. Bootstrap documents `.invisible` as hidden from assistive technology; use `.visually-hidden` for screen-reader-accessible content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.