← Back to Bootstrap Course | Chapter 9: Layout Utilities | Lesson 5 of 7

Visibility

Visibility utilities hide elements visually while keeping or removing their space.

In this page:

  1. Visibility
Syntax
markup
<div class="invisible">hidden but keeps space</div>
<span class="visually-hidden">screen reader text</span>

Visibility

.visible and .invisible toggle visibility but keep the element's space. .visually-hidden hides content visually while leaving it available to screen readers, and .visually-hidden-focusable shows it when focused, perfect for skip links. d-none removes the element from layout entirely.

Note: Use visually-hidden for labels that only screen readers need.

Example: Visibility

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <p>Before <span class="invisible">(invisible keeps space)</span> after</p>
  <p>Before <span class="d-none">(d-none removes)</span> after</p>
  <button class="btn btn-primary"><span class="visually-hidden">Add to cart</span>+</button>
  <a class="visually-hidden-focusable" href="#main">Skip to content (visible when focused)</a>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Using d-none when screen readers need the text
  2. Confusing invisible with d-none
  3. Hiding focusable elements
Chapter Summary
  • invisible keeps the space
  • d-none removes the element
  • visually-hidden stays available to screen readers
  • visually-hidden-focusable for skip links
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.