Boxes, text and decoration
How every element takes up space, how to make text comfortable to read, and how to add colour, depth and shape with a few lines of CSS.
About 5 hours of study
Learning objectives
- Calculate the real size of any box
- Set readable typography
- Add depth with gradients and shadows
Lessons
- 1
The box model
Every element is a box made of content, padding, border and margin. Learn how sizes are calculated, why margins collapse, and how to centre a block.
- 2
Text and fonts
Choose font stacks, load web fonts without blocking the page, and set line height, line length and spacing so that long text is pleasant to read.
- 3
Backgrounds, borders and shadows
Use colours, images and gradients as backgrounds, then round corners and add shadows to give flat boxes a sense of depth.
Module practice
- Padding, border and marginEasy
- Make the sizes add upMedium
- A centred, readable articleHard
- Set the page's fontsEasy
- Make an article comfortable to readMedium
- Load a web font properlyHard
- A soft, rounded cardEasy
- A gradient heroMedium
- Avatars, pills and layered shadowsHard