The CSS border-radius property rounds the corners of an element's outer border edge. It transforms rectangular elements into shapes with rounded or circular corners. Before CSS3 introduced border-radius, developers used background images or nested elements to achieve rounded corners -- a tedious and inflexible approach.
Today, border-radius is universally supported and used extensively in modern web design for cards, buttons, avatars, badges, modals, and virtually every UI component.
The border-radius property accepts length values (px, em, rem) or percentages. It can take 1 to 4 values:
/* Single value: all corners */
border-radius: 10px;
/* Two values: top-left/bottom-right, top-right/bottom-left */
border-radius: 10px 20px;
/* Three values: top-left, top-right/bottom-left, bottom-right */
border-radius: 10px 20px 30px;
/* Four values: top-left, top-right, bottom-right, bottom-left */
border-radius: 10px 20px 30px 40px;
Use a slash to specify different horizontal and vertical radii:
/* Horizontal / Vertical */
border-radius: 50px / 25px;
/* Each corner with horizontal / vertical */
border-radius: 10px 20px 30px 40px / 5px 10px 15px 20px;
Understanding the shorthand is essential for writing concise CSS. The order follows the clock: top-left, top-right, bottom-right, bottom-left.
/* All corners 10px */
border-radius: 10px;
/* Equivalent to: 10px 10px 10px 10px */
/* Horizontal pairs */
border-radius: 10px 20px;
/* Top-left & bottom-right: 10px
Top-right & bottom-left: 20px */
/* Three values */
border-radius: 10px 20px 30px;
/* Top-left: 10px
Top-right & bottom-left: 20px
Bottom-right: 30px */
/* Four values (most explicit) */
border-radius: 10px 20px 30px 40px;
/* Top-left: 10px, Top-right: 20px
Bottom-right: 30px, Bottom-left: 40px */
For maximum control, use the individual corner properties:
border-top-left-radius: 10px;
border-top-right-radius: 20px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 40px;
/* Elliptical individual corners */
border-top-left-radius: 50px 25px;
border-bottom-right-radius: 0;
Use longhand properties when you need to override a single corner without affecting others, especially in responsive designs or component variants:
.card {
border-radius: 12px;
}
.card--top {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.card--bottom {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
The unit you choose significantly affects how border-radius behaves across different element sizes.
/* Fixed 8px radius regardless of element size */
.button-small { width: 80px; height: 32px; border-radius: 8px; }
.button-large { width: 200px; height: 48px; border-radius: 8px; }
/* Both have identically-sized corners */
/* 50% = circle on square, ellipse on rectangle */
.avatar { width: 48px; height: 48px; border-radius: 50%; }
/* 25% scales with element */
.card-small { width: 200px; height: 150px; border-radius: 25%; }
.card-large { width: 400px; height: 300px; border-radius: 25%; }
/* Corners scale proportionally */
Use px for consistent UI components (buttons, cards, inputs) where you want the same corner appearance regardless of size. Use % for avatars, circles, or elements where the rounding should scale with the element. Most design systems define border-radius tokens in pixels.
CSS border-radius can create perfect circles and ellipses without any additional markup.
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background: #326CE5;
}
/* Avatar circle */
.avatar {
width: 48px;
height: 48px;
border-radius: 50%;
overflow: hidden; /* Clip image to circle */
}
.avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.ellipse {
width: 200px;
height: 100px;
border-radius: 50%;
/* 50% on a non-square creates an ellipse */
}
/* Custom elliptical corners */
.organic {
width: 200px;
height: 150px;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.pill {
padding: 8px 24px;
border-radius: 9999px; /* Very large value = pill */
}
/* Alternative */
.pill-alt {
height: 40px;
border-radius: 20px; /* Half the height = pill */
}
Asymmetric border-radius values create organic, creative shapes:
/* Leaf shape */
.leaf {
width: 150px;
height: 150px;
border-radius: 0 50% 0 50%;
background: #22c55e;
}
/* Drop shape */
.drop {
width: 100px;
height: 100px;
border-radius: 50% 50% 50% 0;
background: #3b82f6;
transform: rotate(-45deg);
}
/* Blob */
.blob {
width: 200px;
height: 200px;
border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
background: linear-gradient(135deg, #667eea, #764ba2);
}
/* Speech bubble corner */
.speech {
border-radius: 20px 20px 20px 0;
padding: 1rem;
background: #e5e7eb;
}
Design systems use CSS custom properties to define consistent border-radius tokens:
:root {
--radius-none: 0;
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-xl: 16px;
--radius-2xl: 24px;
--radius-full: 9999px;
}
.button { border-radius: var(--radius-md); }
.card { border-radius: var(--radius-lg); }
.avatar { border-radius: var(--radius-full); }
.input { border-radius: var(--radius-md); }
.modal { border-radius: var(--radius-xl); }
.badge { border-radius: var(--radius-full); }
/* Tailwind's default border-radius scale */
rounded-none = 0px
rounded-sm = 0.125rem (2px)
rounded = 0.25rem (4px)
rounded-md = 0.375rem (6px)
rounded-lg = 0.5rem (8px)
rounded-xl = 0.75rem (12px)
rounded-2xl = 1rem (16px)
rounded-3xl = 1.5rem (24px)
rounded-full = 9999px
Adjust border-radius at different breakpoints for optimal appearance on mobile and desktop:
.card {
border-radius: 8px;
}
@media (min-width: 768px) {
.card {
border-radius: 16px;
}
}
/* Full-width mobile cards often remove top rounding */
@media (max-width: 640px) {
.card--full {
border-radius: 0;
margin-left: -1rem;
margin-right: -1rem;
}
}
@container (min-width: 400px) {
.card {
border-radius: 16px;
}
}
@container (max-width: 399px) {
.card {
border-radius: 8px;
}
}
/* Correct nested radius: inner = outer - padding */
.outer {
border-radius: 16px;
padding: 8px;
}
.inner {
border-radius: 8px; /* 16px - 8px */
}
/* Wrong: same radius looks mismatched */
.outer-bad {
border-radius: 16px;
padding: 8px;
}
.inner-bad {
border-radius: 16px; /* Too much - corners don't align */
}
Our free CSS Border Radius Generator lets you create rounded corners visually and export production-ready CSS.
Create CSS border-radius visually with our free generator. Adjust each corner, switch between px and %, and copy production-ready CSS -- all in your browser.
Try the Border Radius GeneratorMaster box shadows: offset, blur, spread, inset, and multiple shadows.
Master linear, radial, and conic gradients with color stops and effects.
Learn CSS minification techniques and performance optimization.