</> ConvertAtlas Developer Tools
Level 1 · Beginner — CSS Foundations Lesson 10 Beginner 12 min

Working With Images and Cards

Make images responsive and combine everything you know into a polished card component.

Images and cards appear on almost every site. Once you can make images behave and assemble a card, you can build most of a real page. This lesson combines everything so far.

Responsive images

The golden rule: <code>img { max-width: 100%; height: auto; }</code>. This makes images shrink to fit their container and never overflow, while keeping their proportions.

HTML
<div class="frame"><img src="https://picsum.photos/600/300" alt="Demo"></div>
CSS
.frame{max-width:320px}
img{max-width:100%;height:auto;display:block;border-radius:10px}
Result
A responsive image that never overflows.

object-fit for consistent thumbnails

When images must be a fixed size (like thumbnails), <code>object-fit: cover</code> fills the box without distortion by cropping nicely.

Building a card

A card combines a background, padding, rounded corners, a subtle shadow and content. The <code>box-shadow</code> property adds depth: <code>box-shadow: 0 8px 24px rgba(0,0,0,.1)</code>.

HTML
<div class="card"><img src="https://picsum.photos/400/200" alt=""><div class="body"><h3>Card title</h3><p>A short description.</p></div></div>
CSS
.card{max-width:280px;background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 8px 24px rgba(0,0,0,.12)}
.card img{width:100%;height:140px;object-fit:cover;display:block}
.body{padding:16px}
.body h3{margin:0 0 6px}
.body p{margin:0;color:#555}
Result
A complete card component.
Common mistake
Don't
img { width: 600px; }
Do
img { max-width: 100%; height: auto; }

Letting images overflow their container because max-width was not set. Always cap images to 100% of their box.

Best practice

Use overflow: hidden on the card plus border-radius so the image corners are clipped to match. Keep shadows subtle — large soft shadows look more modern than dark ones.

Try it yourself

Build a card with an image (object-fit: cover), a title, a paragraph, padding, rounded corners and a soft box-shadow. Cap the image height.

Quick quiz

1. What makes images responsive?

2. What fills a fixed box without distortion?

3. What adds depth to a card?

Key takeaways
  • Responsive images: max-width:100%; height:auto.
  • object-fit: cover fills fixed boxes without distortion.
  • A card = background + padding + radius + soft shadow.
  • Use overflow:hidden + radius to clip image corners.