CSS border-radius Explained: 8-Value Syntax and Percentages

Last updated: · 6 min read

border-radius is usually written with a single value, but the full property takes eight: one horizontal and one vertical radius for each of the four corners. Pill buttons, cards rounded only at the top and organic blob shapes are all different combinations of those eight values. The CSS Border-Radius Generator gives every corner its own slider, works in px or percent and writes the result in the shortest valid shorthand. This guide explains which value goes to which corner, what the slash means, which box percentages are measured against and what the browser does when the radii do not fit on a side. The snippets in the example are real output from the tool.

Formula

border-radius: <top-left> <top-right> <bottom-right> <bottom-left>
border-radius: <4 horizontal radii> / <4 vertical radii>

Omitted values:
  1 value   → all four corners
  2 values  → top-left and bottom-right | top-right and bottom-left
  3 values  → top-left | top-right and bottom-left | bottom-right

Corner overlap: f = min(side length ÷ sum of the two radii on that side)
  if f < 1, every radius is multiplied by f

Values start at the top-left corner and go clockwise. Without a slash each corner is a quarter circle; with one, the values before it are horizontal radii and those after it vertical radii, so the corner becomes a quarter ellipse. With percentages the horizontal radius refers to the width of the border box and the vertical radius to its height, which is why 50% gives a circle on a square box and an ellipse on a rectangle. If the two radii on a side add up to more than that side, the browser scales down all radii by the same factor f, not just the offending corners. If either radius of a corner is 0, that corner stays square. Negative values are invalid.

What the inputs mean

Unit
px or %. In pixel mode the sliders run from 0 to 200, in percent mode from 0 to 100. Switching from px to percent caps any value above 100 at 100.
Top left, Top right, Bottom right, Bottom left
The radius of each corner. With the elliptical option off, one slider sets both the horizontal and the vertical radius.
Set horizontal and vertical radii separately (elliptical corners)
When ticked, each corner gets two sliders and the code uses the slash syntax. Unticking it resets the vertical radii to the horizontal ones.
Generated code
The tool reduces the values to the shortest form: one value if all corners match, two if opposite corners match, and no slash if horizontal and vertical radii are the same. Zero is written as a unitless 0.

Worked example: From card header to blob: seven settings, seven outputs

  1. The tool opens with all four corners at 40 px. Code: border-radius: 40px;
  2. Round only the top corners (a tab or card header): Top left 24, Top right 24, Bottom right 0, Bottom left 0. Code: border-radius: 24px 24px 0 0;
  3. Pair up opposite corners: Top left 8, Top right 40, Bottom right 8, Bottom left 40. Bottom right equals top left and bottom left equals top right, so the tool shortens it to two values: border-radius: 8px 40px;
  4. With four different corners nothing can be dropped: Top left 40, Top right 10, Bottom right 40, Bottom left 20 gives border-radius: 40px 10px 40px 20px; (bottom left differs from top right, so all four are written).
  5. Switch the unit to % and set all corners to 50. Code: border-radius: 50%; The preview box is not square, so the result is an ellipse, not a circle.
  6. Tick the elliptical option; set the horizontal radii to 30, 70, 70, 30 and the vertical radii to 30, 30, 70, 70. Code: border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; On every side the two radii add up to exactly 100 %, so nothing is scaled down and no straight edge remains: an organic blob.
  7. Go back to px, untick the elliptical option and set all corners to 200. Code: border-radius: 200px; The preview box is 160 px tall; the two radii on its left side add up to 400 px, so f = 160 ÷ 400 = 0.4 and every radius becomes 80 px. The result is a pill.

Result: The same property can be written with one value (40px), two (8px 40px), four (24px 24px 0 0) or eight (30% 70% 70% 30% / 30% 30% 70% 70%); the tool always outputs the shortest valid form.

⬜ CSS Border-Radius Generator

Free, no sign-up; your data stays in your browser.

Open the calculator →

How to read the result

Three patterns cover most everyday work. For pill-shaped buttons and tags, use a pixel value larger than the height of the box: the overlap rule brings the radius down to half the height on its own, and the ends stay semicircular however wide the box grows. A true circle needs a square box and 50%. For two nested rounded boxes to look concentric, make the inner radius smaller than the outer one by the gap between them; the specification itself defines the radius of the inner edge as the outer radius minus the border thickness. A single horizontal/vertical pair is valid too: for horizontal 80 and vertical 20 on all corners the tool outputs border-radius: 80px / 20px; Backgrounds and borders are clipped to the curve, but an image inside is only clipped when overflow is something other than visible.

Common mistakes

  • Assuming 50% always gives a circle. Percentages are resolved against the width horizontally and the height vertically, so on a rectangle the result is an ellipse.
  • Using a percentage for a pill shape. 50% turns the ends into ellipses; a large pixel value such as 200px gives semicircular ends.
  • Reading the values as top, right, bottom, left. margin and padding count sides; border-radius counts corners and starts at the top left.
  • Treating the slash as a separator between pairs of corners. Everything before “/” is the horizontal radius of the four corners and everything after it the vertical radius; the shorthand rules apply to each side of the slash separately.
  • Enlarging one corner a lot and wondering why the others shrink. When radii overlap, the browser scales all of them by the same factor, not only the corner that overflows.
  • Raising the radius because an image pokes out of a rounded box. The fix is overflow: hidden on the container, or a radius on the image itself.

Frequently asked questions

Which corners do the four border-radius values apply to?

Top left, top right, bottom right and bottom left, in that order: clockwise from the top left. If bottom left is omitted it takes the top-right value; if bottom right is omitted it takes the top-left value.

What does the slash in border-radius mean?

The values before it are horizontal radii and the values after it vertical radii. When the two differ, the corner is a quarter ellipse instead of a quarter circle.

How do I make a perfect circle?

Give border-radius: 50% to a box whose width and height are equal. If the box is not square you get an ellipse.

What is the difference between border-radius: 50% and 9999px?

50% gives every corner half the width and half the height as radii, which is an ellipse on a rectangle. A very large pixel value is reduced by the overlap rule to half of the shorter side, which produces a pill.

What happens if the radius is larger than the box?

The browser scales all radii down by the same factor until the two radii on each side no longer exceed its length. Corners never overlap and the declaration stays valid.

Why does a rounded corner not clip the image inside?

The box's own background and border are clipped to the curve, but child content is only clipped when overflow is not visible. Add overflow: hidden to the container.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice