Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS3 border-radius property

CSS3 border-radius property

Runoob Tutorial(runoob.com)

Example

Add rounded borders to two div elements:

#example1

{

border:

2

px

solid

red

;

border-radius:

25

px

;

}

#example2

{

border:

2

px

solid

red

;

border-radius:

50

px

20

px

;

}

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.

property
border-radius 4.0 -webkit- 9.0 4.0 -moz- 5.0 -webkit- 10.5 -o-

Property definition and usage

border-radius allows you to set rounded outer borders on an element. When one radius is used it determines a circle; when two radii are used it determines an ellipse. The intersection of this circle (ellipse) with the border forms the rounded corner effect.

The border-radius property is a shorthand property that can specify up to four border-*-radius properties

Tip: This property allows you to add rounded borders to an element!

Default value: 0
Inherited: no
Version: CSS3
JavaScript syntax: object object.style.borderRadius="5px"

Syntax

border-radius:

1-4 length

|

%

/

1-4 length

|

%

;

Note: The order of the four values for each radius is: 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.

Value Description
length Defines the shape of the corner.
% Use % to define the shape of the corner.

border-radius

:

1em

/

5em

;

/* 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

;

/* 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

;

Elliptical border - border-radius: 15px 50px 30px 5px: the first value applies to the top-left corner, the second to the top-right, the third to the bottom-right, and the fourth to the bottom-left:

Elliptical border - border-radius: 15px 50px 30px: the first value applies to the top-left corner, the second to the top-right and bottom-left, and the third to the bottom-right:

Elliptical border - border-radius: 15px 50px: the first value applies to the top-left and bottom-right corners, the second to the top-right and bottom-left

Elliptical border - border-radius: 15px: this value applies to all four corners, with equal rounding

Try it »


More examples

Example

Background image with border:

#rcorners3

{

border-radius:

25

px

;

background:

url

(

paper

.

gif

)

;

background-position:

left

top

;

background-repeat:

repeat

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

Try it »

Example

Different types of parameters:

#rcorners7

{

border-radius:

50

px

/

15

px

;

background:

#8AC007

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

#rcorners8

{

border-radius:

15

px

/

50

px

;

background:

#8AC007

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

#rcorners9

{

border-radius:

50

%

;

background:

#8AC007

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

Try it »

Example

Different number of parameters:

#rcorners4

{

border-radius:

15

px

50

px

30

px

5

px

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

#rcorners5

{

border-radius:

15

px

50

px

30

px

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

#rcorners6

{

border-radius:

15

px

50

px

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

#rcorners7

{

border-radius:

15

px

;

padding:

20

px

;

width:

200

px

;

height:

150

px

;

}

Try it »

Example

Shorthand form:

#example1

{

border-radius:

2

em

/

5

em

;

}

/*

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:

2

em

1

em

4

em

/

0.5

em

3

em

;

}

/*

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 »


Related Articles

CSS3 tutorial: CSS3 Borders