Bootstrap 4 – Lists

Bootstrap 4 comes with two types of list utility class. The first type allows for creating unstyled lists, while the second type allows for the creation of inline lists. Let’s look at each type individually.

Unstyled lists

The list style can be changed using the list helper classes. An example of where unstyled lists are used in Bootstrap is the pagination and list-inline classes.

To create an unstyled list, apply the list-unstyled class to any ul or ol element. Bootstrap defines the class as follows:

<ul >
  <li>My first unstyled item</li>
  <li>My second unstyled item</li>
  <li>My third unstyled item</li>
  <li>My first styled item</li>
  <li>My second styled item</li>
  <li>My third styled item</li>
Figure 8.9: Contrasting unstyled lists created using the list-unstyled class with normal, styled lists

Inline lists

In some cases, one might need to create lists whose items are displayed inline. By applying the list-inline class to any ul or ol element and applying the list-inline-item class to its li child elements, the list will render inline as the list-inline class sets the list-style to none, and the list-inline-item sets the display property for the li elements to inline-block:

<ul class="list-inline">
  <li class="list-inline-item">My first inline item</li>
  <li class="list-inline-item">My second inline item</li>
  <li >My third inline item</li>
  <li>My first item</li>
  <li>My second item</li>
  <li>My third item</li>
Figure 8.10: Contrasting inline lists created using the list-inline class with normal lists

Comments are closed.