Skip to content

CSS Tutorial CSS Borders

CSS Border Radius

Lesson 33 of 182 2 min read By Deepak Paswan Updated Oct 4, 2026

border-radius rounds the corners of an element. The larger the value, the rounder the corner.

index.html
HTML
<style>
  .box { background: #1a5276; color: white; padding: 14px; margin-bottom: 8px; }
  .a { border-radius: 4px; }
  .b { border-radius: 16px; }
  .c { border-radius: 30px 4px; }
</style>
<div class="box a">4px: slightly soft</div>
<div class="box b">16px: friendly card</div>
<div class="box c">30px 4px: top-left and bottom-right are round</div>

One to four values

Like margins, you can give several values. With four, they go top-left, top-right, bottom-right, bottom-left. With two, the first is for top-left and bottom-right, and the second for the other pair.

Circles and pills

index.html
HTML
<style>
  .avatar { width: 80px; height: 80px; border-radius: 50%; background: #d94a00; display: inline-block; vertical-align: middle; }
  .pill { border-radius: 999px; background: #1a5276; color: white; padding: 8px 20px; display: inline-block; }
</style>
<span class="avatar"></span>
<span class="pill">Add to basket</span>
  • 50% on a square element makes a perfect circle. On a rectangle it makes an oval.
  • A very large value such as 999px makes the shortest sides fully round: a pill. The browser caps the radius, so there is no harm in using a big number.

It clips the background, not the content

The background and border follow the rounded corners, but child content that reaches the corner can still poke out. Add overflow: hidden to the rounded element to clip images inside it. See CSS Overflow.

Exercise: round avatar

Make an img 100px by 100px with a circle shape.

Show a possible solution
style.css
CSS
img { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }

object-fit: cover stops a non-square photo from being squashed.