247

I want to display a list inline using Bootstrap. Is there a class I can add from Bootstrap to achieve this?

10 Answers 10

592

Bootstrap 2.3.2

<ul class="inline">
  <li>...</li>
</ul>

Bootstrap 3

<ul class="list-inline">
  <li>...</li>
</ul>

Bootstrap 4

<ul class="list-inline">
  <li class="list-inline-item">Lorem ipsum</li>
  <li class="list-inline-item">Phasellus iaculis</li>
  <li class="list-inline-item">Nulla volutpat</li>
</ul>

source: http://v4-alpha.getbootstrap.com/content/typography/#inline

Updated link https://getbootstrap.com/docs/4.4/content/typography/#inline

Bootstrap 5.x

<ul class="list-group list-group-horizontal">
  <li class="list-group-item">An item</li>
  <li class="list-group-item">A second item</li>
  <li class="list-group-item">A third item</li>
</ul>

Source: https://getbootstrap.com/docs/5.0/components/list-group/#horizontal And: https://getbootstrap.com/docs/5.2/components/list-group/#horizontal

Sign up to request clarification or add additional context in comments.

4 Comments

Best answer because of presenting solutions to all available versions! Thanks mate!
Why does it get more verbose over time? Doesn't Bootstrap realize they're running in the opposite direction of simplicity?
@PavelKomarov I think very few people care about simplicity or elegance, otherwise why would Bootstrap be so popular and Semantic UI on the verge of extinction?
@iconoclast as a mostly back-end guy who still needs to mess around with front-end, the answer seems obvious to me - for basic needs I can get it up & running faster, easier without having to invest too much of my time to learn the basics to get me started.
58

According to Bootstrap documentation of 2.3.2 and 3, the class should be defined like this:

Bootstrap 2.3.2

<ul class="inline">
  <li>...</li>
</ul>

Bootstrap 3

<ul class="list-inline">
  <li>...</li>
</ul>

Comments

43

While TheBrent's answer is true in general, it does not answer the question of how to do it in the official bootstrap way. The markup for bootstrap is simple:

<ul class="inline">
  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>

Source

http://jsfiddle.net/MgcDU/4602/

4 Comments

@coneybeare for some reason it ain't working. TheBrent solution worked well enough :)
Maybe you are using an ancient version of bootstrap. The bootstrap docs clearly show this is the markup.
Coneybeares solution is the bootstrap specific version and answers the question asked. But, its the web and everything isn't as Black and White as we would like, so whatever solution saves you time thats the one I would use. If one doesn't work, try the other and move on.
the @coneybeare solution is simply the bootstrap2 solution, that's why is not working, nothing more, nothing less!
34

To complete Raymond's answer

Bootstrap 2.3.2

<ul class="inline">
  <li>...</li>
</ul>

Bootstrap 3

<ul class="list-inline">
  <li>...</li>
</ul>

Bootstrap 4

<ul class="list-inline">
  <li class="list-inline-item">Lorem ipsum</li>
  <li class="list-inline-item">Phasellus iaculis</li>
  <li class="list-inline-item">Nulla volutpat</li>
</ul>

source: http://v4-alpha.getbootstrap.com/content/typography/#inline

2 Comments

looks, it gets longer and longer.
Bootstrap 7 <ul class="unordered-list-inline-horizontal-flat-oneline">
15

I couldn't find anything specific within the bootstrap.css file. So, I added the css to a custom css file.

.inline li {
    display: inline;
}

Comments

9

I Amazed, list-inline wasn't working in bootstrap 4 then finally i got it in bootstrap 4 documentation.

Bootstrap 3 and 4

<ul class="list-inline">
  <li class="list-inline-item">Lorem ipsum</li>
  <li class="list-inline-item">Phasellus iaculis</li>
  <li class="list-inline-item">Nulla volutpat</li>
</ul>

Source: http://v4-alpha.getbootstrap.com/content/typography/#inline

Comments

2

Bootstrap 5:

<ul class="list-group list-group-horizontal">
  <li class="list-group-item">An item</li>
  <li class="list-group-item">A second item</li>
  <li class="list-group-item">A third item</li>
</ul>

Comments

1

This solution works using Bootstrap v2, however in TBS3 the class INLINE. I haven't figured out what is the equivalent class (if there is one) in TBS3.

This gentleman had a pretty good article of the differences between v2 and v3.

http://mattduchek.com/differences-between-bootstrap-v2-3-and-v3-0/

EDIT - use CSS to target the li elements to solve your problem as below

    { display: inline-block; }

In my situation I was targeting the UL, instead of the LI

    nav ul li { display: inline-block; }

Comments

-2

Inline is not actually the inline we maybe require - i.e. display:inline

Bootstrap inline as far as I observer is more of a horizontal orientation

To display the list inline with other elements then we do need

display: inline; added to the UL

<ul class="unstyled inline" style="display:inline">

NB// Add to stylesheet

Comments

-2

According to the Bootstrap documentation, you need to add the class 'inline' to your list; like this:

<ul class="inline">
    <li>Item one</li>
    <li>Item two</li>
    <li>Item three</li>
</ul>

However, this does not work as there seems to be some CSS missing in the Bootstrap CSS file referring to the class 'inline'. So additionally, add the following lines to your CSS file to make it work:

ul.inline > li, ol.inline > li {
    display: inline-block;
    padding-right: 5px;
    padding-left: 5px;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.