Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap Badges

Bootstrap Badges

This chapter explains Bootstrap Badges. Badges are similar to labels, the main difference being that badges have more rounded corners.

Badges are mainly used to highlight new or unread items. To use a badge, simply add it to elements such as links and Bootstrap navigation.

The following example demonstrates this:

Example

Display unread mail:

<a href="" Mailbox>
<span class="badge" 50 span a>

Try it »

The result is as follows:

When there are no new or unread items, the badge will collapse via the CSS ** :empty** selector, indicating that there is no content inside.

Example

Display unread messages:

<div class="container">
<h2 Badge h2>
<p>

The .badge class specifies the number of unread messages:

p

<p>
<a href="" Inbox>
<span class="badge" 21 span a p div>

Try it »


Active navigation state

You can place badges in the active state of pill navigation and list navigation. By using to activate the link, as shown in the following example:

Example

<

h4

Active state in pill navigation

h4

<ul class=">

nav nav-pills

"

<li class="active">
<a href="" Home>
<span class="badge" 42 span a li>
<li>
<a href="" Introduction a li>
<li>
<a href="" Message>
<span class="badge" 3 span a li ul>
<br>
<h4>

Active state in list navigation

h4

<ul class=">

nav nav-pills nav-stacked

"

style

=

"

max-width: 260px;

"

<li class="active">
<a href="">
<span class=">

badge pull-right

"

42

span

Home

a

li

<li>
<a href="" Introduction a li>
<li>
<a href="">
<span class=">

badge pull-right

"

3

span

Message

a

li

ul

Try it »

The result is as follows: