Chapter practice task
Task: Style a services card with real spacing, fonts and a background
- Add
* { box-sizing: border-box; }to the top of your stylesheet. - Build a card with a title, text and button, and give it padding, a border and a rounded corner.
- Load a Google Font for headings and a readable font for body text.
- Give the hero section a background image with a dark overlay so white text stays readable.
- Check the card in DevTools and read the box model diagram.
By the end of this chapter
- You can control spacing with padding, border and margin, and fix “extra space” problems
- You can add Google Fonts and set a readable type scale
- You can use background images, gradients and overlays
Quick answers for this chapter
What’s the difference between margin and padding?
Padding is space inside the element’s border; margin is space outside it.
How many fonts should a site use?
One or two. Usually one for headings and one for body text.
Do background images hurt speed?
Large ones can. Compress them and use WebP to keep pages fast.