CSS border-radius Property

CSS

border-radius

Property

Example

Add rounded corners to two <div> elements:

#example1 {
  border: 2px solid red;
 
border-radius: 25px;
}

#example2 {
 
border: 2px solid red;
  border-radius: 50px
20px;
}

Try it Yourself »

More “Try it Yourself” examples below.

Definition and Usage

The border-radius property defines the radius of the
element’s corners.

Tip: This property allows you to add rounded corners to elements! 

This property can have from one to four values. Here are the rules:

Four values – border-radius: 15px 50px 30px 5px; (first value applies to top-left
corner, second value applies to top-right corner, third value applies to bottom-right corner, and fourth value applies to bottom-left corner):

Three values – border-radius: 15px 50px 30px; (first value applies to top-left
corner, second value applies to top-right and bottom-left corners, and third value applies to bottom-right corner):

Two values – border-radius: 15px 50px; (first value applies to top-left and bottom-right corners, and the second value applies to top-right and bottom-left corners):

One value – border-radius: 15px; (the value applies to all four corners, which are rounded equally:

Show demo ❯

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Numbers followed by -webkit- or -moz- specify the first version that worked with a prefix.

Property

border-radius
5.0
4.0 -webkit-
9.0
4.0
3.0 -moz-
5.0
3.1 -webkit-
10.5

CSS Syntax

border-radius: 1-4 length|% / 1-4 length|%|initial|inherit;

Note: The four values for each radius are given in the order top-left, top-right,
bottom-right, bottom-left. If bottom-left is omitted it is the same as
top-right. If bottom-right is omitted it is the same as top-left. If top-right
is omitted it is the same as top-left.

Property Values

More Examples

Example

Set rounded corners for an element with a background color:

#rcorners1 {
  border-radius: 25px;
  background: #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}

Try it Yourself »

Example

Set rounded corners for an element with a border:

#rcorners2 {
  border-radius: 25px;
  border: 2px solid #73AD21;
  padding: 20px;
  width: 200px;
  height: 150px;
}

Try it Yourself »

Example

Set rounded corners for an element with a background image: 

#rcorners3 {
  border-radius: 25px;
  background: url(paper.gif);
  background-position: left top;
  background-repeat: repeat;
  padding: 20px;
  width: 200px;
  height: 150px;
}

Try it Yourself »

Example

Also notice this: 

#example1 {
  border-radius: 2em / 5em;
}
/* is equivalent to:
border-top-left-radius: 2em 5em;
border-top-right-radius: 2em 5em;
border-bottom-right-radius: 2em 5em;
border-bottom-left-radius: 2em 5em; */

#example2 {
  border-radius: 2em 1em 4em / 0.5em 3em;
}
/* is equivalent to:
border-top-left-radius: 2em 0.5em;
border-top-right-radius: 1em 3em;
border-bottom-right-radius: 4em 0.5em;
border-bottom-left-radius: 1em 3em; */

Try it Yourself »

Related Pages

CSS tutorial: CSS Rounded Corners

HTML DOM reference: borderRadius property