Bootstrap Cards
What is a Card?
A card is a flexible box for showing content such as a product, a blog post or a user profile. It can include an image, a title, text, links and buttons.
Basic Card
html
<div class="card" style="width: 18rem;">
<img src="photo.jpg" class="card-img-top" alt="Mountain">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">A short description about this card.</p>
<a href="#" class="btn btn-primary">Read More</a>
</div>
</div>
| Class | Purpose |
|---|---|
card | The outer box |
card-img-top | Image at the top |
card-body | Padded content area |
card-title | Title |
card-subtitle | Smaller line under the title |
card-text | Paragraph text |
card-link | Links inside the card |
Result
A neat box with a photo at the top, a title, a line of text and a blue button.
Header and Footer
html
<div class="card">
<div class="card-header">Featured</div>
<div class="card-body">
<h5 class="card-title">Special title</h5>
<p class="card-text">Some content.</p>
</div>
<div class="card-footer text-muted">2 days ago</div>
</div>
List Group in a Card
html
<div class="card">
<ul class="list-group list-group-flush">
<li class="list-group-item">HTML</li>
<li class="list-group-item">CSS</li>
<li class="list-group-item">JavaScript</li>
</ul>
</div>
Card Colors
html
<div class="card text-bg-primary mb-3">
<div class="card-body">A blue card with white text.</div>
</div>
<div class="card border-success mb-3">
<div class="card-body text-success">A card with a green border.</div>
</div>
Horizontal Card
html
<div class="card mb-3">
<div class="row g-0">
<div class="col-md-4">
<img src="photo.jpg" class="img-fluid rounded-start h-100 object-fit-cover" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">Horizontal card</h5>
<p class="card-text">Image on the left, text on the right.</p>
</div>
</div>
</div>
</div>
Image Overlay
html
<div class="card text-bg-dark">
<img src="photo.jpg" class="card-img" alt="...">
<div class="card-img-overlay">
<h5 class="card-title">Text on image</h5>
<p class="card-text">Written over the picture.</p>
</div>
</div>
Responsive Card Grid
html
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card h-100">
<img src="1.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card 1</h5>
<p class="card-text">Short text.</p>
</div>
</div>
</div>
<!-- repeat the .col for more cards -->
</div>
Why h-100?
h-100 makes all cards in one row the same height, even if the text length is different.
Conclusion
Cards are a very popular component. You can build blog layouts, product lists and team pages with just the classes above.
Quick Summary: card + card-body is the base. Add images, header, footer, list groups and place cards in a row-cols grid.

