Introduction
Bootstrap Icons let you add small pictures (icons) to your website easily. They make buttons and menus clearer and prettier.
Bootstrap Icons let you add small pictures (icons) to your website easily. They make buttons and menus clearer and prettier.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<head> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"> </head>
<i class="bi bi-alarm"></i>
<button><i class="bi bi-cart"></i> Add to Cart</button>
This complete HTML page shows how to set up Bootstrap Icons and use them inside text and buttons. The icons are accessible with proper labels and roles.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap Icons Setup</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"> <style> body { font-family: Arial, sans-serif; padding: 2rem; background-color: #f9f9f9; } button { font-size: 1.2rem; padding: 0.5rem 1rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; background-color: #007bff; color: white; border: none; border-radius: 0.3rem; } button:hover { background-color: #0056b3; } </style> </head> <body> <h1>Bootstrap Icons Example</h1> <p>Here is an alarm icon: <i class="bi bi-alarm" aria-label="Alarm icon" role="img"></i></p> <button aria-label="Add to cart"> <i class="bi bi-cart" aria-hidden="true"></i> Add to Cart </button> </body> </html>
aria-label or role="img" on icons to help screen readers understand them.<i> tags with the right classes to show icons anywhere.<head> tag to load before the page renders.<i> tags with classes starting with bi and the icon name.bi bi-house, used inside an <i> tag.<i class='bi bi-alarm'></i>
<i> tag with classes bi bi-alarm shows the alarm clock icon.<i class='bi bi-camera'></i>But the icon does not appear. What is the most likely reason?
<button> element with an aria-label for screen readers.<i class='bi bi-search'></i> inside the button and add Bootstrap button classes for styling.aria-label improves screen reader clarity.Pass the test and this pattern moves unknown