Cards and images
Compose cards with images, text and actions, and keep images responsive.
What you will be able to do
- Use card and card-body as the base.
- Use img-fluid for responsive images.
- Set width and height to reserve space.
- Keep the whole card clickable only when the action is unambiguous.
In plain English
A card is a flexible container, not a magical component. Combine card-body, card-title and card-text, and use img-fluid plus explicit dimensions to avoid layout shift. Keep one clear action per card.
<article class="card h-100">
<img src="https://picsum.photos/400/200" class="card-img-top" alt="Placeholder cover" width="400" height="200">
<div class="card-body d-flex flex-column">
<h2 class="card-title h5">CSS Grid</h2>
<p class="card-text">Layout without hacks.</p>
<a class="btn btn-primary mt-auto" href="/tutorials/css">Open course</a>
</div>
</article>Your turn
EasyMake a card with a footer
Add a card-footer with a small muted timestamp.
HTML · starter
<div class="card">Check your understanding before moving on.
Knowledge checkQuestion 1
Which class makes an image scale down inside its container?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.