What is border-radius?
The CSS border-radius property rounds the corners of an element's outer border edge. It is one of the most frequently used CSS properties — nearly every modern UI features rounded corners on buttons, cards, inputs, and images. While most developers use a single value like border-radius: 8px, the full syntax is significantly more powerful and supports up to eight values separated by a forward slash (/).
The values before the slash define the horizontal radii for each corner in clockwise order: top-left, top-right, bottom-right, bottom-left. The values after the slash define the vertical radii in the same order. When horizontal and vertical radii differ for a corner, the result is an elliptical curve rather than a circular one. This is how designers create organic, blob-like shapes that go far beyond simple rounded rectangles. You can also use shorthand forms: a single value applies to all four corners, two values set top-left/bottom-right and top-right/bottom-left respectively, and three values set top-left, then top-right/bottom-left together, then bottom-right.
The border-radius property also affects the clipping of the element's content, background, and any box-shadow applied to it. When you round the corners of a container, the background and any overflow content are clipped to the rounded shape. This is why border-radius: 50% on a square element creates a circle — the background is clipped to the elliptical (in this case, circular) boundary defined by the radii. Understanding this clipping behavior is important when working with images, backgrounds, and overflow content inside rounded elements.
How to use this tool
Start in Simple mode for everyday rounded corners: drag the four sliders to set each corner independently, or check "Link all corners" to adjust all four at once. Switch to Advanced mode when you need creative freeform shapes — you get eight sliders controlling both the horizontal and vertical radius of each corner independently. Choose your preferred unit (px, %, or rem) from the dropdown. The preview box updates in real time, and both CSS outputs are always ready to copy.
The Simple mode is ideal for common UI tasks like rounding card corners, creating pill buttons, or making circular avatars. The Advanced mode unlocks the full 8-value syntax, which is necessary for creating asymmetric shapes, organic blobs, and creative design elements. Experiment with setting very different horizontal and vertical values on opposite corners to see how the shape morphs. The preview updates instantly, making it easy to iterate until you find exactly the shape you want.
Practical examples
Pill-shaped buttons and tags
Pill shapes are fully rounded on the left and right sides, creating a capsule-like appearance. The trick is to use a border-radius value that is larger than half the element's height. Using 9999px ensures the pill shape works at any size without needing to know the exact height.
.pill-button {
display: inline-flex;
align-items: center;
padding: 0.5rem 1.5rem;
border-radius: 9999px;
background: #7c9eff;
color: #0f0f11;
font-weight: 600;
border: none;
cursor: pointer;
}
.tag {
display: inline-block;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
background: #1e293b;
color: #94a3b8;
font-size: 0.75rem;
}
Organic blob shapes with 8-value syntax
By setting different horizontal and vertical radii for each corner, you can create organic, asymmetric shapes that feel natural and playful. These blob shapes are popular for decorative backgrounds, avatars, and hero sections.
.blob {
width: 300px;
height: 300px;
background: linear-gradient(135deg, #7c9eff, #4ade80);
border-radius: 70% 30% 50% 50% / 30% 50% 50% 70%;
}
.blob-alt {
width: 250px;
height: 250px;
background: linear-gradient(45deg, #f472b6, #7c9eff);
border-radius: 40% 60% 65% 35% / 55% 35% 65% 45%;
}
/* Animate between blob shapes on hover */
.blob-animated {
border-radius: 70% 30% 50% 50% / 30% 50% 50% 70%;
transition: border-radius 0.6s ease;
}
.blob-animated:hover {
border-radius: 30% 70% 50% 50% / 50% 30% 70% 50%;
}
Asymmetric card corners for design accents
Instead of rounding all corners equally, selectively rounding specific corners creates a distinctive design language. This technique works well for cards, image containers, and feature callouts.
/* Round only the top corners */
.card-top-rounded {
border-radius: 16px 16px 0 0;
overflow: hidden;
}
/* Accent corner — one large rounded corner */
.card-accent {
border-radius: 4px 4px 32px 4px;
padding: 2rem;
background: #1e293b;
}
/* Diagonal rounding — opposite corners */
.card-diagonal {
border-radius: 24px 4px 24px 4px;
padding: 2rem;
background: #1e293b;
}
/* Image with one rounded corner for editorial look */
.editorial-image {
border-radius: 0 0 48px 0;
overflow: hidden;
}
Common patterns and best practices
Follow these guidelines to use border-radius effectively across your designs:
- Use
border-radius: 9999pxinstead of calculating exact pixel values for pill shapes. This value is guaranteed to create the maximum possible rounding on any element, regardless of its dimensions. - Set
overflow: hiddenon containers with border-radius when they contain images or other content that might visually overflow the rounded corners. Without this, content can peek out beyond the rounded edges. - Use percentage values (
%) when you want the radius to scale proportionally with the element's size. Use pixel values (px) when you want a consistent, fixed rounding regardless of element size. Useremwhen the radius should scale with the root font size. - When using
border-radiuswithbox-shadow, the shadow automatically follows the rounded shape. This means you do not need to do anything extra — the shadow conforms to the border-radius automatically. - For circular avatars, use
border-radius: 50%combined withaspect-ratio: 1to ensure the element is always square, producing a perfect circle at any size. - Remember that
border-radiusapplies to the outer edge of the border. If your element has a thick border, the inner radius (the rounding visible inside the border) will be smaller — specifically, it is the outer radius minus the border width.
Browser Support
- border-radius (basic) — universal support since the early 2010s. No prefixes needed in any modern browser.
- 8-value syntax with slash — supported in every evergreen browser; no version-specific issues.
- border-top-left-radius, etc. longhands — same broad support, useful for overriding a single corner without re-declaring the shorthand.
- Spec — defined in CSS Backgrounds and Borders Module Level 3.
Common Pitfalls
- Don't compute pill radius from the height.
border-radius: 9999pxis the correct, content-agnostic pill. The browser clamps it. Never writeborder-radius: calc(var(--btn-height) / 2)— it will desync the moment a designer changes padding. - Without overflow: hidden, content escapes rounded corners. If your card has an image at the top, the image's square corners will pop out past the parent's rounding unless you set
overflow: hidden(or apply the same border-radius to the image). - Don't animate between drastically different blob shapes. The interpolation is mathematically smooth but visually it can look like the element is having a seizure. Constrain transitions to subtle variations of the same blob.
- Inner corners look smaller with thick borders. If you have a 4px border and an outer radius of 12px, the visible inner corner is 8px. Adjust outer radius up if you want the inside to feel as round as the outside.
- Percentage radii on non-square elements produce ellipses, not circles.
50%only gives a circle when the element is a perfect square. Combine withaspect-ratio: 1when the goal is a circular avatar.
FAQ
What does the slash (/) mean in border-radius?
The slash separates the horizontal radii from the vertical radii. For example, border-radius: 50% 50% 50% 50% / 30% 30% 70% 70% means all four corners have a 50% horizontal radius, but the top corners have a 30% vertical radius and the bottom corners have a 70% vertical radius. This creates an elliptical curve at each corner rather than a circular one, which is the key to creating organic blob shapes with pure CSS.
How do I create a perfect circle?
To create a perfect circle, set border-radius: 50% on an element that has equal width and height (a square). You can also use border-radius: 9999px to create a pill shape that works on any rectangle — the browser clamps the radius to half the shortest side, so you always get the maximum possible rounding regardless of the element's dimensions.
Why does my element not become a perfect circle with border-radius: 50%?
The element must have equal width and height for border-radius: 50% to produce a circle. If the width and height differ, 50% creates an ellipse instead, because the horizontal radius is 50% of the width and the vertical radius is 50% of the height — two different values. To fix this, set both dimensions to the same value, or use aspect-ratio: 1 to enforce a square aspect ratio. For example, width: 100px; aspect-ratio: 1; border-radius: 50%; always produces a perfect circle.
Can I animate border-radius?
Yes, border-radius is fully animatable with CSS transitions and animations. The browser smoothly interpolates between the start and end radius values, making it easy to create morphing shape effects on hover or state changes. For example, you can transition from a rounded rectangle to a circle on hover, or animate between two different blob shapes using @keyframes. All eight values (four horizontal and four vertical radii) are interpolated independently, enabling complex morphing effects.
What is the maximum value for border-radius?
There is no fixed maximum value. If the combined radii of two adjacent corners on the same edge exceed that edge's length, the browser proportionally reduces all radii until they fit within the element's dimensions. This is defined in the CSS specification as the "corner curve overlap" algorithm. In practice, this means border-radius: 9999px safely creates the maximum possible rounding on any element — the browser clamps it down to the actual available space automatically. You never need to worry about setting a value that is "too large."
Related guides
- All CSS Guides — in-depth tutorials on modern CSS
- 10 Modern CSS Features