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
CSS
border-radius: 12px;Shorthand examples
| Corners | Shortest border-radius | Why |
|---|---|---|
| 12px, 12px, 12px, 12px | 12px | All four corners equal: one value. |
| 8px, 16px, 8px, 16px | 8px 16px | Top-left equals bottom-right and top-right equals bottom-left: two values. |
| 8px, 16px, 24px, 16px | 8px 16px 24px | Only top-right and bottom-left equal: three values. |
| 0, 0, 24px, 24px | 0 0 24px 24px | Rounded at the bottom only: no pair is equal, so all four stay. |
| 8px, 16px, 24px, 32px | 8px 16px 24px 32px | Every corner different: four values, clockwise from top-left. |
| 0.5rem, 0.5rem, 0.5rem, 0.5rem | 0.5rem | rem 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, 0 | 20px 20px 0 0 / 10px 10px 0 0 | Each side of the slash collapses on its own. |
| 12px, 12px, 12px, 12px / 12px, 12px, 12px, 12px | 12px | Equal horizontal and vertical radii need no slash. |
Percentages and overlap on a 200 × 100 px box
| CSS | Radius before scaling | Scale factor | Drawn radius |
|---|---|---|---|
| border-radius: 12px | 12px × 12px | 1 (fits) | 12px × 12px |
| border-radius: 25% | 50px × 25px | 1 (fits) | 50px × 25px |
| border-radius: 50% | 100px × 50px | 1 (fits) | 100px × 50px |
| border-radius: 75% | 150px × 75px | 0.667 | 100px × 50px |
| border-radius: 9999px | 9999px × 9999px | 0.005 | 50px × 50px |
Units and limits
| Unit | Measured against | Largest value here |
|---|---|---|
| px | Absolute CSS pixels. | 10,000px |
| % | The box: width for the horizontal radius, height for the vertical one. | 100% |
| rem | The root font size, 16px by default, so it follows the visitor’s text size setting. | 1,000rem |
The presets
| Preset | Corners | border-radius |
|---|---|---|
| Subtle | 4px, 4px, 4px, 4px | 4px |
| Rounded | 12px, 12px, 12px, 12px | 12px |
| Pill | 9999px, 9999px, 9999px, 9999px | 9999px |
| Ellipse | 50%, 50%, 50%, 50% | 50% |
| Leaf | 0, 48px, 0, 48px | 0 48px |
| Blob | 60%, 40%, 30%, 70% / 60%, 30%, 70%, 40% | 60% 40% 30% 70% / 60% 30% 70% 40% |
How to make a CSS border radius
- 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.
- 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.
- 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.
- 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.
- 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 free tools
- CSS Box Shadow GeneratorLayer CSS box shadows with offset, blur, spread, color and inset, preview them live, copy the CSS or Tailwind class, or paste a shadow to edit it.
- CSS Gradient GeneratorBuild linear, radial and conic CSS gradients with up to 8 color stops, preview them live, copy the CSS or a Tailwind class, and check text contrast.
- PX to REM ConverterConvert px to rem, em, pt, % and vw/vh with an editable root font size, see a px to rem table, or paste CSS and convert every px value to rem at once.
- Color Converter & Contrast CheckerConvert HEX to RGB, HSL, HWB, CMYK and OKLCH and back, find the nearest CSS color name, and check WCAG 2 contrast for AA and AAA text.
- CSS Minifier & BeautifierMinify CSS safely or beautify it with 2 or 4 space indents. Strings, url() and calc() stay intact. Shows bytes saved and gzip size. Runs in your browser.
- CSS Flexbox GeneratorSet flex-direction, justify-content, align-items, wrap, gap and item grow, shrink and basis, see the layout live, and copy the CSS and HTML.
More: Color and CSSAll developer toolsAll toolsHome & DIY calculators