<span class="badge bg-primary">New</span>
The badge class creates a small label with rounded corners. The bg-primary class gives it a blue background and white text by default.
<nav> element with Bootstrap. Which selector correctly selects them?The selector nav .badge selects any element with class badge inside a nav element, at any depth.
The status role announces changes politely to assistive technologies without interrupting the user.
<button type="button" class="btn btn-primary position-relative"> Notifications <span class="badge bg-danger position-absolute top-0 start-100 translate-middle">3</span> </button>
The button needs position-relative so the badge's position-absolute is relative to it. The classes top-0 start-100 translate-middle place the badge overlapping the top-right corner.
<span class="badge bg-primary" aria-label="New messages" role="button">New</span>
The code is valid HTML and renders correctly. However, using role="button" on a non-clickable badge can confuse assistive technology users because it suggests the element is interactive when it is not.
