Print utilities
Print utilities control what appears when a page is printed.
In this page:
Syntax
<nav class="d-print-none">hidden when printing</nav>
<div class="d-none d-print-block">only when printing</div>
Print utilities
Use .d-print-none to hide elements such as navigation when printing, .d-print-block or .d-print-inline to show print-only content and .d-none .d-print-block for print-only headers.
Combine with screen classes like d-none d-print-block. Test with the browser's print preview.
Note:
Hide navbars, buttons and ads from printed pages with d-print-none.
Example: Print utilities
<!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">
<div class="d-print-none alert alert-secondary">This banner is hidden when printing.</div>
<div class="d-none d-print-block">This text is only visible on the printed page.</div>
<p>This paragraph appears on screen and in print.</p>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Forgetting to hide navigation
- Printing with dark backgrounds
- Not testing print preview
Chapter Summary
- d-print-none hides when printing
- d-print-block shows only when printing
- Combine with d-none
- Check the print preview
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: