To create rounded corners in CSS, set the border-radius property on an element, for example border-radius: 8px. The value is the radius of the circle that rounds each corner, and a very large value or 50% on a square turns the box into a circle. This guide covers css border-radius syntax, per-corner values, elliptical corners and common patterns.
A length such as 8px or 0.5rem gives a fixed radius. A percentage is relative to the box: horizontally to its width and vertically to its height. That is why 50% makes a square a circle but a rectangle an ellipse.
The radius rounds the background and border. It also clips the background image and, with overflow: hidden, the child content.
The shorthand takes one to four values, starting at the top-left and going clockwise.
| Values | Meaning |
|---|---|
10px | All four corners |
10px 20px | Top-left and bottom-right 10px, top-right and bottom-left 20px |
10px 20px 30px | Top-left 10px, top-right and bottom-left 20px, bottom-right 30px |
10px 20px 30px 40px | Top-left, top-right, bottom-right, bottom-left |
You can also use longhands.
Logical longhands such as border-start-start-radius follow the writing direction, which helps in right-to-left layouts.
Each corner can have a different horizontal and vertical radius. Write horizontal values, a slash, then vertical values.
The leaf rounds only the top-left and bottom-right corners with elliptical curves. The blob uses organic percentages to create an irregular shape without any image.
On an img, border-radius clips the picture itself. On a container, overflow: hidden is needed so child images or colored headers do not poke out of the rounded corners. object-fit: cover stops a non-square photo from being squashed inside a round avatar.
The curve follows the outer edge of the border, and the inner edge gets a smaller radius automatically (outer radius minus border width, never below zero). box-shadow and outline follow the rounded shape in current browsers, so a card with a shadow keeps soft corners.
If radii on adjacent corners add up to more than the side length, browsers scale all radii down proportionally, so the shape stays valid. This is why 999px makes a clean pill: the radii shrink until they fit exactly half the height.
rem for radii when you want them to scale with user font size settings, or px when you want a fixed look.Give the element equal width and height and set border-radius: 50%.
Set border-top-left-radius and border-top-right-radius, or use the shorthand border-radius: 12px 12px 0 0.
Add overflow: hidden to the container, or put border-radius directly on the img.
It works on table cells and, with border-collapse: separate, on tables. With border-collapse: collapse the radius does not apply to the table borders.
border-radius rounds corners with one to four values, longhands for single corners and a slash syntax for elliptical shapes. Use 50% for circles, a large value for pills and overflow: hidden to clip children. Reuse a few consistent radii across the design.