Skip to main content
ponderloop

CSS Border Radius Generator (Four Corners, Elliptical, Pill)

A CSS border radius rounds the corners of a box. Setting every corner to 12px is border-radius: 12px; The shorthand collapses equal values, so it is written once instead of four times. Link or unlink the four corners, choose px, % or rem, switch on the elliptical a / b syntax, and copy the shortest CSS.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Preview

Set the corners

Presets

CSS

border-radius: 12px;

Shorthand examples

Each row is built by the generator above from the corners shown, in the order top-left, top-right, bottom-right, bottom-left.
CornersShortest border-radiusWhy
12px, 12px, 12px, 12px12pxAll four corners equal: one value.
8px, 16px, 8px, 16px8px 16pxTop-left equals bottom-right and top-right equals bottom-left: two values.
8px, 16px, 24px, 16px8px 16px 24pxOnly top-right and bottom-left equal: three values.
0, 0, 24px, 24px0 0 24px 24pxRounded at the bottom only: no pair is equal, so all four stay.
8px, 16px, 24px, 32px8px 16px 24px 32pxEvery corner different: four values, clockwise from top-left.
0.5rem, 0.5rem, 0.5rem, 0.5rem0.5remrem works like px; 0.5rem is 8px at the default 16px root size.
50%, 50%, 50%, 50%50%Percentages: 50% on a square makes a circle, on other boxes an ellipse.
50%, 50%, 50%, 50% / 25%, 25%, 25%, 25%50% / 25%Elliptical: horizontal radius, a slash, then vertical radius.
20px, 20px, 0, 0 / 10px, 10px, 0, 020px 20px 0 0 / 10px 10px 0 0Each side of the slash collapses on its own.
12px, 12px, 12px, 12px / 12px, 12px, 12px, 12px12pxEqual horizontal and vertical radii need no slash.

Percentages and overlap on a 200 × 100 px box

A percentage is measured against the box: horizontal radius against its width, vertical radius against its height. When two radii on one side add up to more than that side, the browser scales every radius down by one factor.
CSSRadius before scalingScale factorDrawn radius
border-radius: 12px12px × 12px1 (fits)12px × 12px
border-radius: 25%50px × 25px1 (fits)50px × 25px
border-radius: 50%100px × 50px1 (fits)100px × 50px
border-radius: 75%150px × 75px0.667100px × 50px
border-radius: 9999px9999px × 9999px0.00550px × 50px

Units and limits

UnitMeasured againstLargest value here
pxAbsolute CSS pixels.10,000px
%The box: width for the horizontal radius, height for the vertical one.100%
remThe root font size, 16px by default, so it follows the visitor’s text size setting.1,000rem

The presets

Each row is a preset of the generator above, written by the same function.
PresetCornersborder-radius
Subtle4px, 4px, 4px, 4px4px
Rounded12px, 12px, 12px, 12px12px
Pill9999px, 9999px, 9999px, 9999px9999px
Ellipse50%, 50%, 50%, 50%50%
Leaf0, 48px, 0, 48px0 48px
Blob60%, 40%, 30%, 70% / 60%, 30%, 70%, 40%60% 40% 30% 70% / 60% 30% 70% 40%

How to make a CSS border radius

  1. Pick a unit. Choose px for a fixed size, % to scale with the box, or rem to follow the text size. The same unit applies to every corner.
  2. Set the corners. With the corners linked, one number sets all four. Unlink them to set the top left, top right, bottom right, bottom left corners one by one. A preset such as Pill or Leaf is a quick start.
  3. Add the elliptical option if you need it. Switch on elliptical corners to give each corner a horizontal and a vertical radius. The CSS then reads horizontal / vertical, and the slash is left out when they are equal.
  4. Check the preview. The box in the preview is wider than it is tall, so you can see how percentages and large values behave on a box that is not square.
  5. Copy the CSS. Choose Copy CSS. Equal values are already collapsed: the example is 12px; rather than four repeated values.

Frequently asked questions

How does the border-radius shorthand work?
It takes one to four values in the order top-left, top-right, bottom-right, bottom-left. A missing value copies the one opposite it, so one value sets all corners, two values set the two diagonals, and three values reuse the top-right for the bottom-left. For the corners 8px, 16px, 24px, 32px the shortest form is 8px 16px 24px 32px.
How do I collapse equal corners into the shortest shorthand?
Compare the values: if all four are equal write one (8px); if top-left equals bottom-right and top-right equals bottom-left write two (8px 16px); if only top-right equals bottom-left write three (8px 16px 24px). The generator does this for you, for the horizontal and vertical lists separately.
What does a percentage border radius mean?
A percentage is relative to the size of the box, not to the font: the horizontal radius is a share of the width and the vertical radius a share of the height. On a 200 × 100 px box, 25% is 50px across and 25px down, so the corner is an ellipse, not a circle. Use px or rem when you want a true circular corner on a box that is not square.
How do I make a circle or an ellipse?
Set border-radius to 50%. On a square box it is a circle; on any other box each corner is an ellipse that meets the next one at the middle of the side, giving an ellipse. The Ellipse preset is 50%.
How do I make a pill or stadium shape?
Use a radius larger than half the box height, such as 9999px. The browser scales the radii down until they fit (see the overlap table), so the ends become perfect half circles at any height without you knowing the height. 50% does not work for this: on a wide box it gives an ellipse, not a pill. Set the radius in px so that it does not depend on the width.
What does the slash in border-radius do?
It separates the horizontal radii from the vertical radii, so each corner can be an ellipse instead of a circle: 50% / 25% gives every corner a horizontal radius of half the width and a vertical radius of a quarter of the height. Without a slash both radii of a corner are equal. The Blob preset is 60% 40% 30% 70% / 60% 30% 70% 40%.
Why does my large radius look smaller than I typed?
If the radii on one side add up to more than that side, the browser multiplies all radii by one factor until they fit. On a 200 × 100 px box 9999px is drawn as a 50px radius, which is why a huge value gives a pill and not a broken shape. The scaling is by the same factor for every corner, so unequal corners keep their proportions.
Should I use px or rem for border radius?
Use px when the radius should stay the same whatever the visitor’s text size, as on icons and images. Use rem when the radius belongs to text-sized things such as buttons and badges, so it grows with larger text settings. At the default 16px root size 0.5rem is 8px; the px to rem converter on this site does the arithmetic for other values.
Can I round only one or two corners?
Yes. Unlink the corners and set the others to 0, which the generator writes without a unit. For example 0 48px rounds the top-right and bottom-left corners only. You can also use the single-corner properties such as border-top-left-radius, but the shorthand is shorter.
Is anything I enter sent anywhere?
No. The numbers are read and the CSS is built in your browser, and nothing you type is stored or sent anywhere.

How it works

Each corner has a horizontal and a vertical radius. The generator reads every number you type (digits and a decimal point only, never negative; at most 10,000px, 100% or 1,000rem), rounds it to three decimals, and writes it with the chosen unit, or as a bare 0. The four corners are listed in CSS order (top-left, top-right, bottom-right, bottom-left) and collapsed the way CSS Backgrounds and Borders Level 3 defines the shorthand: if the top-right equals the bottom-left the list can drop the fourth value, if the top-left also equals the bottom-right it can drop the third, and if all four are equal it is one value. With elliptical corners the vertical list is collapsed on its own and written after a slash, unless every vertical radius equals its horizontal one. In the overlap table a percentage is converted against the box size, rem at 16 pixels, and the scale factor is the smallest value of side length divided by the sum of the two radii on that side, never more than 1, as in the Corner Overlap rule of the specification. The preview applies the same value to a box 14 rem wide and 8 rem tall. Everything runs in your browser and nothing you enter is sent anywhere.

Sources

More: Color and CSSAll developer toolsAll toolsHome & DIY calculators