Course contentsShow
← Web Development
Lesson 201 of 2,9823. CSS FundamentalsFree lesson

Border Radius

Create rounded corners with border-radius, including elliptical corners and individual corner control.

Border Radius

What you'll learn: How to soften sharp rectangle corners into smooth, rounded edges using CSS.

The Core Idea

By default, HTML elements are sharp-cornered rectangles. border-radius lets you round those corners, creating anything from subtle softness to perfect circles. Think of it like taking sandpaper to the corners of a wooden box—you're smoothing the edges.

The property accepts length values (px, rem, etc.) or percentages, controlling how much curvature to apply.

Basic Syntax

.box {
  border: 2px solid black;
  border-radius: 10px; /* All four corners rounded equally */
}

The value represents the radius of an invisible circle placed at each corner—larger values create more pronounced rounding.

Individual Corner Control

You can target specific corners using shorthand (clockwise from top-left) or individual properties:

/* Shorthand: top-left, top-right, bottom-right, bottom-left */
.card {
  border-radius: 10px 20px 30px 40px;
}

/* Individual properties */
.custom {
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

Elliptical Corners

Use two values separated by a slash to create oval-shaped corners (horizontal radius / vertical radius):

.ellipse {
  border-radius: 50px / 25px; /* Wider than tall */
}

/* Per-corner elliptical */
.fancy {
  border-radius: 40px 20px 30px 10px / 20px 40px 10px 30px;
}

Creating Circles

Set border-radius: 50% on a square element to create a perfect circle:

.circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

Key Takeaway: border-radius transforms rigid rectangles into friendlier shapes—use single values for uniform rounding, four values for individual corners, or the slash notation for elliptical curves.