Rounded corners have been a staple of modern web design for over a decade. The CSS border-radius property transforms sharp-edged boxes into smooth, approachable shapes — from subtle corner softening to perfect circles and organic blobs. This guide covers everything from basic syntax to advanced techniques, with practical examples you can use in your projects today.
border-radius
The border-radius property rounds the corners of an element's outer border edge. It works on any element with a visible background, border, or box-shadow. The radius value defines the size of the circle (or ellipse) used to round each corner.
/* One value — all four corners */ border-radius: 16px; /* Two values — top/bottom pairs */ border-radius: 16px 8px; /* top-left + bottom-right = 16px, top-right + bottom-left = 8px */ /* Three values */ border-radius: 16px 8px 4px; /* top-left=16, top-right=8, bottom-right=4, bottom-left=8 */ /* Four values — each corner */ border-radius: 16px 8px 4px 2px; /* top-left, top-right, bottom-right, bottom-left (clockwise) */
Use the slash to set horizontal and vertical radii separately, creating elliptical corners:
/* Elliptical: horizontal / vertical */ border-radius: 50% / 30%; /* Each corner is a 50% wide, 30% tall ellipse */ /* Per-corner elliptical */ border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
border-top-left-radius: 16px; border-top-right-radius: 16px; border-bottom-right-radius: 0; border-bottom-left-radius: 0;
4–8px for a subtle, professional feel. Commonly used on cards, inputs, and buttons.
border-radius: 8px;
12–20px for a friendly, modern look. Popular in contemporary UI frameworks.
border-radius: 16px;
Use a very large value (9999px is a common convention) to create pill shapes. The browser clamps the radius to the largest possible curve.
.pill { border-radius: 9999px; } /* Works on buttons, tags, badges, and any rectangular element */
Set border-radius: 50% on a square element to create a circle. On non-square elements, it creates an ellipse.
border-radius: 50%
.circle { width: 100px; height: 100px; border-radius: 50%; }
Round only the top corners to create a ticket-like or tab-like appearance.
.ticket { border-radius: 12px 12px 0 0; }
Use the elliptical slash syntax to create organic, amoeba-like shapes:
.blob { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
Round three corners and leave one sharp:
.leaf { border-radius: 0 50% 50% 50%; }
Box shadows automatically follow the border-radius curve, so rounded elements get rounded shadows:
.card { border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
Borders also follow the border-radius. Thin borders on rounded elements create a clean, defined edge:
.outlined { border-radius: 12px; border: 2px solid #6366f1; }
Border-radius clips content inside the element when combined with overflow: hidden. This is essential for rounded images and containers:
overflow: hidden
.rounded-image { border-radius: 16px; overflow: hidden; } .rounded-image img { width: 100%; display: block; }
Background gradients are also clipped by border-radius, so rounded gradient backgrounds work automatically:
.gradient-card { border-radius: 16px; background: linear-gradient(135deg, #6366f1, #22d3ee); }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.tag { display: inline-block; padding: 4px 12px; border-radius: 9999px; background: rgba(99, 102, 241, 0.15); color: #a78bfa; font-size: 0.85rem; }
.bubble-sent { border-radius: 16px 16px 4px 16px; background: #6366f1; } .bubble-received { border-radius: 16px 16px 16px 4px; background: #1e293b; }
.modal { border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
Consider using relative units for border-radius in responsive designs:
/* Fluid rounding */ .card { border-radius: clamp(8px, 2vw, 24px); } /* Container-relative */ .container { border-radius: min(16px, 5%); }
Set border-radius: 50% on a square element. The element must have equal width and height. If the dimensions differ, border-radius: 50% creates an ellipse instead of a circle. For guaranteed circles, use a specific large value like border-radius: 9999px on a square element.
border-radius: 9999px
Yes. You can set up to four values: border-radius: top-left top-right bottom-right bottom-left. For example, border-radius: 10px 0 10px 0 rounds only the top-left and bottom-right corners. You can also use individual properties like border-top-left-radius.
border-radius: top-left top-right bottom-right bottom-left
border-radius: 10px 0 10px 0
border-top-left-radius
There is no hard maximum value. When border-radius exceeds half the element's width or height, the browser clamps it to create the largest possible curve. Using a very large value like 9999px is a common trick to create pill shapes without needing to know the exact element dimensions.
9999px
Use border-radius: 9999px (or a large value) on your button element. This ensures the corners are as round as possible given the element's height, creating a pill/capsule shape regardless of the button's width: .pill-btn { border-radius: 9999px; padding: 8px 24px; }.
.pill-btn { border-radius: 9999px; padding: 8px 24px; }
🔲 Design rounded corners visually. Try our free Border Radius Generator — adjust each corner independently and copy the CSS.
Visual corner designer with live preview
Add depth to your rounded elements
Find the perfect colors for your UI