Cards
A card is a box for one item, such as a product. It can have an image, a title, text and buttons.
Cards are everywhere on the modern web - product listings, blog previews, profile boxes, pricing plans. A card groups everything about one thing in a neat box with consistent padding, borders and rounded corners. Bootstrap cards have parts (card-img-top, card-body, card-title, card-text) that you can mix as needed.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="card" style="max-width: 18rem;">
<div class="card-header bg-warning-subtle">Deal of the day</div>
<div class="card-body">
<h5 class="card-title">Wireless Earbuds</h5>
<p class="card-text text-muted">Up to 30 hours of battery.</p>
<p class="fs-4 fw-bold mb-2">Rs 1,499 <small class="text-decoration-line-through text-muted fs-6">Rs 2,999</small></p>
<a href="#" class="btn btn-primary">Compare prices</a>
</div>
</div>
</body>
</html>▶ Try it yourselfA row of cards
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="row row-cols-1 row-cols-sm-3 g-3">
<div class="col"><div class="card h-100"><div class="card-body"><h6>Phone</h6><p class="mb-0">Rs 12,999</p></div></div></div>
<div class="col"><div class="card h-100"><div class="card-body"><h6>Laptop</h6><p class="mb-0">Rs 45,990</p></div></div></div>
<div class="col"><div class="card h-100"><div class="card-body"><h6>Tablet</h6><p class="mb-0">Rs 18,500</p></div></div></div>
</div>
</body>
</html>▶ Try it yourselfrow-cols-sm-3 puts three cards in a row from small screens up. h-100 makes all cards the same height.Key points
- A card is a box for one item: image, title, text, buttons.
- Put cards in grid columns to make responsive rows.
h-100makes cards in a row the same height.
📝 Test yourself
1. Which class holds the main content of a card?
2. What does h-100 do on cards in a row?
3. Fill in the class for a card title:
<h5 class="">Earbuds</h5>
