Skip to content
FORGENO ADS GAMESUnlock all $8

CSS · Unit 2: The box model · Lesson 4 of 5

Rounded corners and shadows

border-radius rounds corners.

Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.

The idea

border-radius rounds corners. 8px gives a gentle curve; 50% on a square turns it into a circle, which is handy for profile pictures.

box-shadow adds a shadow: a sideways offset, a downward offset, a blur and a color, like box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15).

Keep shadows soft. A light shadow lifts a card off the page; a heavy black one looks dated.

Worked example

CSS

.card {
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

The HTML it styles

<div class="card">Weekend workshop</div>

Key terms

border-radius
Rounds the corners of a box; 50% on a square makes a circle.
box-shadow
A shadow behind a box: offsets, blur and color, like 0 2px 8px rgba(0, 0, 0, 0.15).

Practise it in Code Academy

It has 4 exercises (multiple choice, fill in the blank, fix the broken code and write code from a prompt) and takes about 5 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.

Every lesson is free: no ads, no lives and no paywall.