css · level 1 · unit 6 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
rounds off the corners.
Sharp corners can look stiff. border-radius rounds them off. A small value like 4px softens them, and a bigger value like 20px makes them really round.
It works with or without a border, because it shapes the background too. Buttons, cards and photos often have rounded corners.
On a square, border-radius: 50% rounds the corners so far that they meet in the middle of each side, and you get a circle. Profile photos are often done this way.
<div class="pill">Rounded</div>
<img class="avatar" src="cat.svg" alt="A cat"> .pill {
background-color: plum;
padding: 12px;
border-radius: 12px;
}
.avatar {
width: 100px;
height: 100px;
border-radius: 50%;
} Press show my page to see it here.
Try 0 on the pill to bring the sharp corners back.
guess first
A square with 50%. What shape do you get?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<div class="dot"></div> .dot {
width: 80px;
height: 80px;
background-color: tomato;
border-radius: 50%;
}
your turn
Your turn. Round off the card.
Give the card rounded corners, anywhere between 6px and 30px.
the page you’re styling
<div class="card">You are invited to my party!</div>your css
Press show my page to see it here.
- the top corners are roundednot checked yet
- the bottom corners are roundednot checked yet
fix it
The photo should be a circle. Can you fix it?
the page you’re styling
<img class="photo" src="dog.svg" alt="A dog">your css
Press show my page to see it here.
- the photo is a circlenot checked yet
- The corners stay sharp. Look at the value.
- A number needs a unit or a
%after it. - Change
50to50%, then press run.
nailed it
you smoothed off the sharp corners. :D
border-radiusrounds the corners of a box.- Bigger values make rounder corners.
border-radius: 50%turns a square into a circle.
new words in your collection
- border-radius
This lesson isn’t saved. A free account remembers every lesson you finish.