Introduction
Visibility utilities help you show or hide parts of your webpage easily without writing custom CSS.
Visibility utilities help you show or hide parts of your webpage easily without writing custom CSS.
Use classes like .d-none, .d-block, .d-sm-none, .d-md-block, etc. Example: <div class="d-none d-md-block">Visible on medium and larger screens</div>
d- control display property (none, block, inline, etc.).-sm-, -md-, -lg- to control visibility on different screen sizes.<div class="d-none">Hidden on all screens</div>
<div class="d-block d-sm-none">Visible only on extra small screens</div>
<div class="d-none d-md-block">Hidden on small, visible on medium and larger</div>
<div class="invisible">Invisible but takes up space</div>
This page shows how different paragraphs appear or hide depending on screen size using Bootstrap visibility utilities.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Visibility Utilities Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="container py-4"> <h1>Visibility Utilities Demo</h1> <p class="d-none d-md-block">This paragraph is only visible on medium and larger screens.</p> <p class="d-block d-md-none">This paragraph is only visible on small screens.</p> <p class="invisible">This paragraph is invisible but still takes space.</p> <p>This paragraph is always visible.</p> </main> </body> </html>
Use d-none to hide elements completely (no space taken).
Use invisible to hide elements but keep their space.
Combine display classes with breakpoints to make your site responsive.
Visibility utilities let you quickly show or hide elements.
Use d-none and d-block with breakpoints for responsive control.
invisible hides content but keeps layout space.
d-none do to an element?d-none class purposed-none class sets display: none; on the element, hiding it completely.d-none hides element fully [OK]d-none means no display at all [OK]d-none with invisibled-none hides the element on all screen sizes. d-md-block makes it display block starting at medium screens and up.d-none d-md-block hides the element on small and extra small screens, shows it on medium and larger.d-none d-md-block [OK]d-none plus breakpoint d-*-block to show [OK]d-block d-md-none which hides on medium screenssm and md breakpoints<div class="invisible">Hello</div>
invisible class effectinvisible class applies visibility: hidden;, hiding the content but keeping its space.invisible hides content but keeps layout space [OK]invisible hides text but keeps space [OK]invisible removes element from layoutinvisible with d-noned-none d-sm-blockd-none hides element on all sizes, d-sm-block shows it from small screens up, so it remains hidden on extra small but visible on small and larger.d-none d-md-block [OK]d-sm-block instead of d-md-blockd-none can be overridden by smaller breakpointd-none d-md-block sets display: none by default (hides completely on xs/sm), then display: block from md up (visible on md+).d-md-visible. D uses invisible which applies visibility: hidden everywhere, so remains hidden even on md+.d-none d-md-block [OK]d-none d-md-block to hide below medium, show from medium [OK]invisible which keeps space but stays hidden on large screensd-md-visiblePass the test and this pattern moves unknown