- Home
- Tools
- Color & Design
- Border Radius Generator
Border Radius Generator
Round each corner separately, or shape an organic blob.
The order of the corners
border-radius takes one to four values. They start at the top left and go round clockwise: top left, top right, bottom right, bottom left. One value applies to all four corners. With two or three, a corner you leave out copies the one diagonally opposite.
| You write | Top left, top right, bottom right, bottom left |
|---|---|
8px | 8, 8, 8, 8 |
8px 24px | 8, 24, 8, 24 |
8px 24px 40px | 8, 24, 40, 24 |
8px 24px 40px 0 | 8, 24, 40, 0 |
The generator always writes the shortest form that still means the same thing, so four equal corners come out as a single value.
What the slash means
A corner does not have to be a quarter of a circle. It has two radii, a horizontal and a vertical one, and together they make a quarter of an ellipse. The values before the slash are the horizontal radii, the values after it the vertical ones, in the same clockwise order.
border-radius: 30% 70% 70% 30% /
30% 30% 70% 70%;
Written on two lines like this, each column is one corner. The top left corner is 30% of the box wide and 30% high, and the top right corner 70% wide and 30% high. Along the top edge the two widths add up to 100%, so no straight piece is left between them. When that holds for all four sides the box becomes a blob. Random blob does exactly this: it cuts each side at a random point between 25% and 75% and gives the two corners on that side one part each.
Percentages count against the width for horizontal radii and against the height for vertical ones. A single value such as 20% therefore already gives elliptical corners on a box that is not square.
Circles, ellipses and pills
border-radius: 50% turns a square into a circle and any other rectangle into an ellipse.
A pill, with straight long sides and fully round ends, needs a radius of half the height. You don't have to know the height: write a radius that is far too large, such as 9999px. When the radii along a side add up to more than the side is long, the browser scales all radii down by the same factor until they fit. On a box of 200 by 48 pixels that factor is 48 ÷ 19998, which leaves every radius at 24px, exactly half the height. 50% cannot do this, because its horizontal radius is half the width.
Two things that catch people out
A rounded box does not cut off its children. An image at the top of a card keeps its square corners and covers the round ones, unless the card has overflow: hidden.
When one rounded box sits inside another, equal radii look wrong: the gap between the curves is wider in the corner than along the sides. Subtract the gap from the outer radius. A card with a 16px radius and 8px padding wants 8px on what is inside it.
Pixels or percent
A radius in pixels stays the same when the box grows, which is what you want for buttons, cards and inputs of different sizes. A radius in percent grows with the box and is the one to use for circles and blobs. The same value also looks different on a small button than on a large card.