Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The border-radius property

Reference for the CSS border-radius property: round box corners with lengths or percentages, set elliptical corners with a slash, with live examples and usage notes.

The border-radius property rounds the corners of an element's box. A radius describes the quarter circle (or quarter ellipse) that replaces the sharp corner: the larger the radius, the rounder the corner. It is a shorthand for the four corner properties border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius.

The rounding is not only visual decoration on the border. The element's background, its box shadow, and (with overflow other than visible) its content are all clipped to the rounded shape.

CSS
.card {
  border-radius: 12px;
}

Try it

Rounded corners

The last two boxes show the difference between 50% and a huge length. On a rectangle, 50% produces an ellipse, while 999px produces a pill: the browser scales the radii down just enough that the curves meet, but the straight edges stay.

Different radius per corner

Syntax

CSS
border-radius: <length-percentage>{1,4} [ / <length-percentage>{1,4} ]?;
  • Initial value: 0
  • Applies to: all elements (but not the internal table elements when border-collapse is collapse)
  • Inherited: no
  • Animatable: yes, as lengths and percentages
  • Computed value: for each corner, two absolute lengths or percentages (horizontal and vertical radius)

Values

Value Description
<length> A fixed radius such as 8px or 0.5rem. Negative values are invalid.
<percentage> Relative to the border box: the horizontal radius uses the width and the vertical radius uses the height. 50% on a square gives a circle.
One value Applies to all four corners.
Two values The first is top-left and bottom-right, the second is top-right and bottom-left.
Three values Top-left, then top-right and bottom-left, then bottom-right.
Four values Top-left, top-right, bottom-right, bottom-left (clockwise from the top-left).
a / b Values before the slash are horizontal radii and values after it are vertical radii, which gives elliptical corners.

Usage notes

  • Overlapping radii are scaled down. If the radii on one side add up to more than the side's length, the browser shrinks all radii by the same factor. That is why a very large value like 999px gives a clean pill shape.
  • Content may poke out. Rounded corners do not clip children by default. Add overflow: hidden (or overflow: clip) to the parent when an image or coloured child would otherwise cover the curve.
  • Outlines and shadows follow the curve. box-shadow is always rounded to match, and modern browsers also curve the outline around the rounded border box.
  • Border images ignore it. A border-image is not rounded by border-radius. Clip with clip-path or use a background-based trick instead.
  • Inner curve. With a thick border, the inner edge of the border has a smaller radius (the outer radius minus the border width, never below zero).
  • Tables. Radii do not work on cells, rows or the table when border-collapse is collapse. Use separate, or round a wrapper element.
  • Logical properties. For layouts that change direction, use border-start-start-radius and its siblings instead of physical corners.

Browser support

Supported in every current browser, with no vendor prefix needed.