Bootstrap's cards provide a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.
Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element. Class .card-img-top places an image to the top of the card.
The building block of a card is the .card-body
. Use it whenever you need a padded section within a card.
Example 1: Bootstrap card with body class
<div class="card"> <div class="card-body"> This is some text within a card body. </div> </div>
Card titles are used by adding .card-title
to a <h*>
tag.
Subtitles are used by adding a .card-subtitle
to a <h*>
tag.
Links are added and placed next to each other by adding .card-link
to an <a>
tag.
All the above items are placed in a .card-body
Example 2: Bootstrap card with title, subtitle, text, link classes.
<div class="card"> <div class="card-body"> <h5 class="card-title">Card title</h5> <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="card-link">Card link</a> <a href="#" class="card-link">Another link</a> </div> </div>
Some quick example text to build on the card title and make up the bulk of the card's content.
Card link Another linkAdd an optional header and/or footer within a card. Card headers can be styled by adding .card-header
to <div>
or <h*>
above .card-body
elements.
Example 3: Card Header using div tag
<div class="card"> <div class="card-header">Featured - Card Header</div> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereExample 4: Card Header using heading tag
<div class="card"> <h5 class="card-header">Featured</h5> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereExample 5: Card displaying quote with card header, body.
<div class="card"> <div class="card-header">Quote</div> <div class="card-body"> <blockquote class="blockquote mb-0"> <p>A well-known quote, contained in a blockquote element.</p> <footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer> </blockquote> </div> </div>
A well-known quote, contained in a blockquote element.
Example 6: Card with header, body, footer.
<div class="card text-center"> <div class="card-header"> Featured </div> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> <div class="card-footer text-muted"> 2 days ago </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereYou can quickly change the text alignment of any card—in its entirety or specific parts using bootstrap text align classes
Card left alignment (default) - .text-start
Example 7: Bootstrap class with left alignment.
<div class="card w-50"> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereExample 8: Bootstrap class with center alignment.
<div class="card text-center w-50"> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereExample 9: Bootstrap class with center alignment.
<div class="card text-end w-50"> <div class="card-body"> <h5 class="card-title">Special title treatment</h5> <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
With supporting text below as a natural lead-in to additional content.
Go somewhereCards include a few options for working with images..card-img-top
places an image to the top of the card
Example 10: Bootstrap top Image card with some content
<div class="card"> <img src="your-image.ext" class="card-img-top" alt="Bootstrap 5 card"> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereExample 11: Bootstrap bottom Image card using .card-img-bottom
with some content
<div class="card"> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> <img src="your-image.ext" class="card-img-bottom" alt="Bootstrap 5 card"> </div>
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereTurn an image into a card background and overlay your card's text using .card-img
and .card-img-overlay
instead of .card-body
Example 12: Bootstrap Image overlays
<div class="card col-lg-4 p-0"> <img src="your-image.ext" class="card-img" alt="Bootstrap 5 card"> <div class="card-img-overlay text-light"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereUsing a combination of grid cards can be made horizontal in a mobile-friendly and responsive way. Remove the grid gutters with .g-0 and use .col-md-* classes to make the card horizontal at the md breakpoint.
Example 13: Bootstrap Horizontal Image
<div class="card" style="max-width: 540px;"> <div class="row g-0"> <div class="col-md-4"> <img src="..." class="img-fluid rounded-start" alt="..."> </div> <div class="col-md-8"> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> </div> </div> </div> </div>
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Last updated 3 mins ago
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards.
Example 14: Bootstrap card group
<div class="card-group"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> </div> </div> <div class="card"> <img src="/images/h1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p> <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> </div> </div> <div class="card"> <img src="/images/h3.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p> <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> </div> </div> </div>
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Last updated 3 mins ago
This card has supporting text below as a natural lead-in to additional content.
Last updated 3 mins ago
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
Last updated 3 mins ago
Example 15: When using card groups with footers, their content will automatically line up.
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This card has supporting text below as a natural lead-in to additional content.
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
Example 16: Bootstrap Card group using Grid cards
<div class="row row-cols-1 row-cols-md-3 g-4"> <div class="col"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> </div> <div class="card-footer"> <small class="text-muted">Last updated 3 mins ago</small> </div> </div> </div> <div class="col"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> </div> <div class="card-footer"> <small class="text-muted">Last updated 3 mins ago</small> </div> </div> </div> <div class="col"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p> </div> <div class="card-footer"> <small class="text-muted">Last updated 3 mins ago</small> </div> </div> </div> <div class="col"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> </div> <div class="card-footer"> <small class="text-muted">Last updated 3 mins ago</small> </div> </div> </div> </div>
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.