CSS PROPERTIES
Expand All|Collapse All
CSS AT-RULES
SPONSORED LINKS

CSS3 border-radius Property

Topic: CSS3 Properties Reference« Prev|Next »

Description

The border-radius CSS property sets the rounded shape for the border corners of an element. It is a shorthand property for border-top-left-radius, border-top-right-radius, border-bottom-right-radius, and border-bottom-left-radius property.

The following table summarizes the usages context and the version history of this property.

Default value: 0
Applies to: All elements
Inherited: No
Animatable: Yes. See animatable properties.
Version: New in CSS3
 

Note:The border-radius property also causes the element's background to be rounded even if no borders have been defined or its value is set to none.


Syntax

The syntax of the property is given with:

border-radius: 
[ length | percentage ] 1 to 4 values 
 \-------------------------------/
            First radii
/ [length | percentage ] 1 to 4 values | initial | inherit
   \------------------------------/
        Second radii (optional)  

This shorthand notation can take one, two, three, or four whitespace separated values.

  • If one value is specified, it defines the radius of all corners.
  • If two values are specified, the first value is used for the top-left and bottom-right corner, while the second value is used for the top-right and bottom-left sides corner.
  • If three values are specified, the first value is used for the top-left corner, the second value is used for the top-right and bottom-left corner, and the third value is used for the bottom-right corner.
  • If four values are specified, each value applies to the border individually in the order top-left, top-right, bottom-right, and bottom-left corner.

The example below shows the border-radius property in action.

  • div {
  •     border: 2px solid #f08080;
  •     border-radius: 20px;
  • }
 

Note:The optional second length values, preceded by a "/", define the vertical radii for the corner and the corner shape is thus a quarter ellipse. If the second length is omitted, or it is equal to the first — the corner shape is a quarter circle. If either length is zero, the corner is square, not rounded.


Property Values

The following table describes the values of this property.

Value Description
length A length value in px, pt, cm, em, etc. Negative values are not allowed.
percentage The size of the radius in percentage. In case of elliptical corners, percentage for the horizontal radius is calculated with respect to the width of the element's box, while percentage for the vertical radius is calculated with respect to the height of the element's box. Negative values are not allowed.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element border-radius property.

Browser Compatibility

The border-radius property is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 4+
  • Google Chrome 4+
  • Internet Explorer 9+
  • Apple Safari 5+
  • Opera 10.5+
 

Warning:Internet Explorer 8 and earlier versions do not support the
border-radius property. supported in IE9 and above.


Further Reading

See tutorial on: CSS Border, CSS3 Border.

Related properties: border-bottom-left-radius, border-bottom-right-radius, border-top-left-radius, border-top-right-radius

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.