ximg.es

Border-radius generator

Adjust each corner separately or draw organic shapes with the eight radii of border-radius. The code shortens itself, the way you’d write it by hand.

CSS code

border-radius: 24px;

Preview image: /480x300/0ea5e9/ffffff.png?text=border-radius

Examples
Mode
Unit
Corners

Preview shape

How border-radius works

Each corner is a quarter of an ellipse. With a single value, such as border-radius: 24px, the ellipse is a circle with a 24 px radius and all four corners match. With four values they go clockwise from the top left: top-left top-right bottom-right bottom-left. Missing values are copied from the opposite corner, just like margin: that’s why 0 120px gives you a leaf.

The eight-value syntax and organic shapes

After the slash come the vertical radii: border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%. Each corner then stops being an arc of a circle and becomes an arc of an ellipse with two different radii, which is how modern websites make blobs without a single image or SVG. “Free shape” mode always works in percentages, so the shape holds even when the element changes size.

px or %: which to use

Rounding images

border-radius also clips the content of an <img>, so it’s all you need for round avatars (border-radius: 50% on a square image). If the element has children that stick out of the corners, add overflow: hidden. The preview uses an image from the ximg.es generator, which you can request at the exact size of your layout:

<img src="https://ximg.es/160x160" style="border-radius: 50%" alt="">

Frequently asked questions

How do I make a circle with CSS?

Use a square element (same width and height) and border-radius: 50%. On a rectangle you get an ellipse.

What does the slash in border-radius mean?

It separates the horizontal radii (before) from the vertical ones (after). With it, each corner can be an arc of an ellipse instead of a circle, which is how organic shapes are drawn.

Why doesn’t my border-radius round the image inside?

Because the radius applies to the container and the child spills over the corners. Add overflow: hidden to the container or apply border-radius to the image itself.

How do I round just one corner?

With the longhand properties, such as border-top-left-radius: 12px, or with four values: border-radius: 12px 0 0 0.

What happens if the radii are bigger than the element?

The browser scales them down proportionally until they fit. That’s why 999px gives a perfect pill rather than a broken shape.

Does it work in every browser?

Yes, including the eight-value syntax, and has done for over ten years. The -webkit- prefix is no longer needed.

More tools

See all tools · Placeholder image generator