The border-radius
CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.
This property is a shorthand to set the four properties border-top-left-radius
, border-top-right-radius
, border-bottom-right-radius
, and border-bottom-left-radius
.
The radius applies to the whole background
, even if the element has no border; the exact position of the clipping is defined by the background-clip
property.
The border-radius
property does not apply to table elements when border-collapse
is collapse
.
border-radius:0 0 inherit inherit
, which would partially override existing definitions. Instead, the individual longhand properties have to be used./* The syntax of the first radius allows one to four values */ /* Radius is set for all 4 sides */ border-radius: 10px; /* top-left-and-bottom-right | top-right-and-bottom-left */ border-radius: 10px 5%; /* top-left | top-right-and-bottom-left | bottom-right */ border-radius: 2px 4px 2px; /* top-left | top-right | bottom-right | bottom-left */ border-radius: 1px 0 3px 4px; /* The syntax of the second radius allows one to four values */ /* (first radius values) / radius */ border-radius: 10px 5% / 20px; /* (first radius values) / top-left-and-bottom-right | top-right-and-bottom-left */ border-radius: 10px 5% / 20px 30px; /* (first radius values) / top-left | top-right-and-bottom-left | bottom-right */ border-radius: 10px 5px 2em / 20px 25px 30%; /* (first radius values) / top-left | top-right | bottom-right | bottom-left */ border-radius: 10px 5% / 20px 25em 30px 35em; /* Global values */ border-radius: inherit; border-radius: initial; border-radius: unset;
The border-radius
property is specified as:
<length>
or <percentage>
values. This is used to set a single radius for the corners.<length>
or <percentage>
values. This is used to set an additional radius, so you can have elliptical corners.radius | Is a <length> or a <percentage> denoting a radius to use for the border in each corner of the border. It is used only in the one-value syntax. | |
top-left-and-bottom-right | Is a <length> or a <percentage> denoting a radius to use for the border in the top-left and bottom-right corners of the element's box. It is used only in the two-value syntax. | |
top-right-and-bottom-left | Is a <length> or a <percentage> denoting a radius to use for the border in the top-right and bottom-left corners of the element's box. It is used only in the two- and three-value syntaxes. | |
top-left | Is a <length> or a <percentage> denoting a radius to use for the border in the top-left corner of the element's box. It is used only in the three- and four-value syntaxes. | |
top-right | Is a <length> or a <percentage> denoting a radius to use for the border in the top-right corner of the element's box. It is used only in the four-value syntax. | |
bottom-right | Is a <length> or a <percentage> denoting a radius to use for the border in the bottom-right corner of the element's box. It is used only in the three- and four-value syntaxes. | |
bottom-left | Is a <length> or a <percentage> denoting a radius to use for the border in the bottom-left corner of the element's box. It is used only in the four-value syntax. |
<length>
<percentage>
For example:
border-radius: 1em/5em; /* ... is equivalent to: */ border-top-left-radius: 1em 5em; border-top-right-radius: 1em 5em; border-bottom-right-radius: 1em 5em; border-bottom-left-radius: 1em 5em;
border-radius: 4px 3px 6px / 2px 4px; /* ... is equivalent to: */ border-top-left-radius: 4px 2px; border-top-right-radius: 3px 4px; border-bottom-right-radius: 6px 2px; border-bottom-left-radius: 3px 4px;
<length-percentage>{1,4} [ / <length-percentage>{1,4} ]?where
<length-percentage> = <length> | <percentage>
border: solid 10px; /* the border will curve into a 'D' */ border-radius: 10px 40px 40px 10px;
border: groove 1em red; border-radius: 2em;
background: gold; border: ridge gold; border-radius: 13em/3em;
border: none; border-radius: 40px 10px;
border: none; border-radius: 50%;
border: dotted; border-width: 10px 4px; border-radius: 10px 40px;
border: dashed; border-width: 2px 4px; border-radius: 40px;
Specification | Status | Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 3 The definition of 'border-radius' in that specification. | Candidate Recommendation | Initial definition |
Initial value | as each of the properties of the shorthand: |
---|---|
Applies to | all elements; but User Agents are not required to apply to table and inline-table elements when border-collapse is collapse . The behavior on internal table elements is undefined for the moment.. It also applies to ::first-letter . |
Inherited | no |
Percentages | refer to the corresponding dimension of the border box |
Media | visual |
Computed value | as each of the properties of the shorthand:
|
Animation type | as each of the properties of the shorthand:
|
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 4
|
12
|
4
|
9 | 10.5
|
5
|
Elliptical borders | Yes
|
12 | 3.5 | Yes | Yes | Yes
|
4 values for 4 corners | 4 | 12 | Yes | Yes | Yes | 5 |
Percentages | Yes
|
12 | 4
|
Yes | 11.5
|
5.1
|
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 2
|
Yes | Yes
|
Yes
|
Yes | Yes | |
Elliptical borders | ? | Yes | Yes | Yes | No | ? | Yes |
4 values for 4 corners | ? | Yes | Yes | Yes | No | ? | Yes |
Percentages | Yes
|
Yes | Yes | Yes | No | Yes
|
Yes |
border-top-left-radius
, border-top-right-radius
, border-bottom-right-radius
, border-bottom-left-radius
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius