Create a card with an image, a title, a text and a button

Description: Create a card 18rem wide with an image on top, a title, a text and a button.

Hint:

  • Use card, card-img-top, card-body, card-title and card-text.

Solution

<div class="card" style="width: 18rem;">
  <img src="images/photo.jpg" class="card-img-top" alt="A sample image">
  <div class="card-body">
    <h5 class="card-title">Learn Bootstrap</h5>
    <p class="card-text">A short text about the course, with some words.</p>
    <a href="#" class="btn btn-primary">Start now</a>
  </div>
</div>
Live preview

How it works

  • The image uses card-img-top, so it fits the top of the card with rounded corners.
  • The text and the button are inside card-body, which gives the padding.

Read Cards.


Learn more about the similar topics:
Tutorials
Bootstrap Buttons
Bootstrap Alerts
Bootstrap Badges
Bootstrap Cards
Bootstrap List Group
Bootstrap Progress Bars and Spinners
Bootstrap Icons
Exercises & Assignments
Create a card with an image, a title, a text and a button
Create an alert which the user can close
Create a progress bar at 60 percent
Create a pricing section with three cards
Create a button group
Add a notification count badge to a button
Create a hero section with a heading and two buttons
Interview Questions & Answers
How do you create buttons in Bootstrap?
How do you make a full width button in Bootstrap 5?
What are Bootstrap alerts and how do you close them?
What is a card in Bootstrap?
How do you use Bootstrap Icons?
How do you make cards of equal height in Bootstrap?