CSS border-radius Property

Add rounded borders 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 borders 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:

Default value: 0
Inherited: no
Animatable: yes. Read about animatable – Try it
Version: CSS3
JavaScript syntax: object.style.borderRadius=”25px” Try it
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
Value Description Code
length Defines the shape of the corners. Default value is 0 div {
border-radius:10px;
}
% Defines the shape of the corners in % div {
border-radius:40%;
}
initial Sets this property to its default value. Read about initial div {
border-radius:initial;
}
inherit Inherits this property from its parent element. Read about inherit

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 »

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 »

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 »

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 »

Post Author: Zahid Farid