How to create: List groups with badges

Learn how to create list groups with badges using CSS.

List groups with badges

  • Inbox 2
  • Other 5
  • Saved
  • Stuff
  • Old

Try It Yourself

How to create list groups

Step 1 - Add HTML:

<ul>
  <li>Inbox <span class="badge">2</span></li>
  <li>Other <span class="badge">5</span></li>
  <li>Saved</li>
  <li>Stuff</li>
  <li>Old</li>
</ul>

Step 2 - Add CSS:

/* Convert basic list to custom list group */
ul.list-group {
  list-style-type: none;
  padding: 0;
  margin: 0;
{}
ul.list-group li {
  border: 1px solid #ddd;
  margin-top: -1px; /* Prevent double borders */
  background-color: #f6f6f6;
  padding: 12px;
{}
/* Set the style for badges within the list group */
ul.list-group .badge {
  background-color: red;
  color: #fff;
  font-weight: bold;
  border-radius: 50%;
  padding: 5px 10px;
  text-align: center;
  margin-left: 5px;
{}

Try It Yourself

Related Pages

Tutorial:CSS List