Coderspace Log In

CSS Border Radius Generator

Round corners with sliders, set all four at once or one by one, switch to elliptical corners and compare px against % instantly. The live preview runs on real box dimensions, and the output always comes out in the shortest correct form you could write by hand.

Corners

Unit

px is a fixed length on every corner and does not change as the box grows.

24px
24px
Options
Presets

Preview and code

320px
200px
Fill

Veri Analitiği

What order does the border-radius shorthand use?

border-radius is a shorthand for four separate properties: border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius. The values you write are read in exactly that order, starting at the top left corner and moving clockwise. The most common mistake is reading them the way margin and padding are read, as top, right, bottom, left. border-radius counts corners, not edges.

Write fewer than four values and the missing corners are copied from the corner opposite them. One value rounds all four equally. Two values give the first to the top left and bottom right, the second to the top right and bottom left. Three values set the top left, then the top right together with the bottom left, then the bottom right. Four values address every corner individually.

Shorthand forms compared

Written as Top left Top right Bottom right Bottom left
8px 8px 8px 8px 8px
8px 24px 8px 24px 8px 24px
8px 24px 4px 8px 24px 4px 24px
8px 24px 4px 16px 8px 24px 4px 16px
40px / 12px 40px across, 12px down 40px across, 12px down 40px across, 12px down 40px across, 12px down

What the slash does, and what an elliptical corner is

By default every corner is a quarter circle, because its horizontal and vertical radius are the same. Add a slash and the declaration splits in two: values on the left set the horizontal radii, values on the right the vertical ones. Each corner becomes a quarter ellipse, and you end up controlling eight numbers rather than four.

Every blob shaped element you have seen on the web is built this way; the four value form cannot produce one, because it forces each corner to be a symmetric arc. The two sides of the slash shorten independently, so 50% / 30% 70% is valid: one value on the left spreads across all four corners while two on the right split into corner pairs.

px versus percent, and why percent distorts

A pixel radius is a fixed length. A 12px corner looks the same whether the box is 100 or 1000 pixels wide. That predictability is why almost every design system sticks to pixels: a component that stretches keeps the same corner.

A percentage is measured against the element itself, and here is the detail people miss. The horizontal radius is a percentage of the box width, while the vertical radius is a percentage of the box height. On a square that produces the same number twice and the corner reads as a circle. On a 320 by 80 box, 20% works out to 64 pixels across and 16 pixels down, and the corner flattens visibly. That is exactly why this tool lets you resize the preview box on both axes.

Why 9999px is the safe pill idiom

The instinct when making a fully rounded button or tag is to reach for 50%, but that gives the wrong shape. A 50% radius takes half the width horizontally and half the height vertically, so on a wide, short box you get an ellipse with pointed ends rather than a pill with clean semicircular caps.

The reliable idiom is a pixel value comfortably larger than the box: 9999px. When the radii do not fit, the browser scales them all down by the same factor, so the radius settles at exactly half the box height and the ends come out as true semicircles. 999px or 100vmax do the same job.

What the browser does when radii overlap

If the two radii along one edge add up to more than the length of that edge, the shape would cut into itself. The specification avoids this with a precise rule: for every edge the browser divides the edge length by the sum of the two radii on it, takes the smallest of those four ratios, and if that value is below one, multiplies every radius by it.

The part worth remembering is that the scaling applies to the whole shape, not to the offending corner alone. Push one corner past what fits and all four shrink together. That rule is what makes the 9999px pill behave identically at any box size.

Corners, overflow and borders

border-radius only clips the element's own background and border. Child elements, absolutely positioned layers and video still spill past the rounded corner. Clipping those needs overflow: hidden on the container, at a cost: a box-shadow on the same element can no longer escape it, position: sticky may stop working inside it, and dropdowns get cut off at the edge.

How far the background reaches is controlled by background-clip. The default border-box paints the background all the way under the border, so a semi transparent border lets it show through. padding-box stops the background at the padding edge instead. When the two borders meeting at a corner have different widths, the browser draws a smooth transition between them, which is why the curve sometimes looks different from what you expected.

Nested boxes need a small calculation: the inner radius should be the outer radius minus the padding between them. If the outer card has a 16px radius and 8px of padding, give the inner element 8px and the two curves stay concentric. Give both 16px and the inner corner reads as rounder than the outer one.

Why CSS cannot draw a real squircle

The squircle used by iOS icons and by a lot of recent interface work is a superellipse. The transition from the straight edge into the curve is continuous rather than abrupt, and that is where the soft shoulder your eye picks up comes from. border-radius places a circular or elliptical arc at each corner, so curvature jumps the moment the edge meets the arc.

The workarounds have been an SVG path, clip-path or a mask. On the CSS side the corner-shape property is being specified for exactly this: corner-shape: superellipse(...) asks the browser to draw a superellipse arc instead of a circular one. Support is only starting to spread, so approximating the look with elliptical radii is still the practical choice in production.

Common mistakes

Once the corners are settled, build a background with the CSS gradient generator and drop it into the preview here to judge both decisions together.

How do you set a CSS border-radius?

  1. 1

    Round the corners

    Set all four corners with a single slider, or turn on the per corner option and give each corner, from top left round to bottom left, its own value. When you switch between px and percent the values are clamped to the range the new unit allows.

  2. 2

    Switch to elliptical corners

    Turning on the eight value form gives every corner its own horizontal and vertical radius, so each one becomes a quarter ellipse instead of a quarter circle. Organic, blob-like shapes are only possible in this form.

  3. 3

    Size the preview box like the real one

    Change the width and the height with the sliders and set the fill to a solid colour, a gradient or an image. This is the only place you can see how a percentage corner flattens out on a box that is not square.

  4. 4

    Pick a preset or copy the code

    Rounded card, pill, circle, squircle, leaf and blob each rewrite the whole state in one click. The output is always written in the shortest correct form; copy the CSS line or the Tailwind class with its own button.

FAQ

Clockwise from the top left: top left, top right, bottom right, bottom left. Corners you leave out are copied from the corner opposite them, so with two values the first covers top left and bottom right while the second covers top right and bottom left. Do not confuse it with the top, right, bottom, left order of margin and padding, because border-radius counts corners rather than edges.

border-radius: 50% is all you need, but only if the box is square. When width and height differ, 50% gives you an ellipse instead, because the horizontal radius is measured against the width and the vertical one against the height. Set aspect-ratio: 1 or equal width and height first, then apply 50%.

Use 9999px. On a wide, short button 50% produces an ellipse with pointed ends. A very large pixel value instead triggers the browser's scaling rule: since the radii do not fit, they are all reduced by the same factor and the radius lands at exactly half the height. The caps stay perfect semicircles no matter how long the button gets.

The slash splits the declaration in two: values before it set the horizontal radii of the corners and values after it set the vertical ones. Each side takes one to four values, so you can control eight numbers in total. Corners become quarter ellipses rather than quarter circles, which is the only way to build the organic blob shapes you see around.

border-radius clips only the element's own background and border, never its children. Either give the image the same radius directly, or add overflow: hidden to the container. If you choose the container, be aware of the trade off: a box-shadow on that same element can no longer escape it and position: sticky may stop working inside it.

The tool also outputs the value as a Tailwind arbitrary class in the rounded-[...] form, with spaces converted to underscores. If the same corner treatment appears across several components, register it as a named entry under borderRadius in tailwind.config instead. It reads better and it is far easier to change later.

Not with classic border-radius. A squircle is a superellipse whose transition from edge to curve is continuous, while border-radius places a circular or elliptical arc at the corner, so curvature jumps at the join. Elliptical radii get you close enough that most people will not notice. For the real thing you still need an SVG path, clip-path or a mask today; the CSS corner-shape property with superellipse() is being specified, but support is still new.

Coderspace is always with you in your tech career!

Learn, code, compete, get hired!

Sign up now