Round the corners of a square part just a little. That alone softens a stiff impression and gives it a much more modern look. When buttons and cards look gentle, it’s usually thanks to this corner roundness. The tool for it is border-radius.
Let’s write one
.card {
border: 2px solid teal;
border-radius: 12px;
}Just add one line, border-radius: 12px;, to a border. The corners of the square frame round off softly. Change the number to 4px or 20px and the degree of roundness changes too. Smaller for a crisp look, larger for a gentle one.
Let’s line up how the corners change for each number.
999px, and both ends become perfect half-circles — a pill shape.Make the number big, and it becomes a full circle
Turn the roundness way up — set it to 50% and, surprisingly, it becomes a full circle. This is a common trick for round icons and profile photos.
.avatar {
width: 80px;
border-radius: 50%;
}Set a square part to border-radius: 50%; and it turns into a clean circle. The moment a square becomes round is like a little bit of CSS magic, and it’s the spot where you feel “it changed!” the most.
Let’s see how the same square changes with 50%.
50%, loses all its corners and becomes a full circle. Matching width and height is the trick to a clean circle.Button-like: fully rounded corners + a “you can click” cue
Turn the corner roundness way up and a square button becomes a pill (capsule) shape. Add cursor: pointer; here and the cursor turns into a pointing hand when the mouse is over it, adding one more cue that says “you can press this.”
.btn {
border-radius: 999px;
cursor: pointer;
}Specify a number that’s reliably too big, like 999px, and any size of part gets perfect half-circles at both ends, finishing as a pill shape.
Give each corner a different roundness
border-radius can actually set each of the four corners separately. Line up four numbers and they apply in the order top-left → top-right → bottom-right → bottom-left.
.tab {
border-radius: 12px 12px 0 0;
}Only the top two corners round, the bottom stays square — you can make shapes like a sticky note, a tab, or a speech bubble. Remember: one number rounds all four corners the same, four numbers let you change each corner.
Let’s see how the shape changes when you change the order of the numbers.
Summary of this lesson
- Corner roundness is
border-radius - The bigger the number, the rounder;
50%makes a full circle - Around
8px–16pxlooks elegant for parts border-radius: 999px;for a pill shape,cursor: pointer;for a “you can press this” cue
