Show/hide by breakpoint
Combine display utilities to show or hide content depending on screen size.
In this page:
Syntax
<div class="d-none d-md-block">hidden below md</div>
<div class="d-lg-none">hidden from lg up</div>
Show/hide by breakpoint
Hide on small screens with d-none d-md-block, hide on large ones with d-lg-none, or show only on a range with combinations such as d-none d-md-block d-xl-none.
Hiding removes content from layout but not from the page, so avoid hiding essential content on mobile.
Note:
Prefer restructuring content over hiding it on small screens.
Example: Show/hide by breakpoint
<!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 text-center">
<div class="d-block d-sm-none bg-danger text-white p-2 mb-1">xs only</div>
<div class="d-none d-sm-block d-md-none bg-warning p-2 mb-1">sm only</div>
<div class="d-none d-md-block d-lg-none bg-success text-white p-2 mb-1">md only</div>
<div class="d-none d-lg-block bg-primary text-white p-2">lg and up</div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Hiding essential content on mobile
- Forgetting the counterpart class
- Using JavaScript for simple show/hide
Chapter Summary
- d-none plus d-{bp}-block shows from a size
- d-{bp}-none hides from a size
- Combine for ranges
- Do not hide essential content
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: