CSS3 Rounded Corners Properties
THE WORLD'S LARGEST WEB DEVELOPER SITE
CSS Tutorial
CSS HOMECSS Introduction
CSS Syntax
CSS How To
CSS Backgrounds
CSS Borders
CSS Margins
CSS Padding
CSS Height/Width
CSS Text
CSS Fonts
CSS Links
CSS Lists
CSS Tables
CSS Box Model
CSS Outline
CSS Display
CSS Max-width
CSS Position
CSS Float
CSS Inline-block
CSS Align
CSS Combinators
CSS Pseudo-class
CSS Pseudo-element
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Image Opacity
CSS Image Sprites
CSS Attr Selectors
CSS Forms
CSS Counters
CSS3
CSS3 IntroductionCSS3 Rounded Corners
CSS3 Border Images
CSS3 Backgrounds
CSS3 Colors
CSS3 Gradients
CSS3 Shadows
CSS3 Text
CSS3 Fonts
CSS3 2D Transforms
CSS3 3D Transforms
CSS3 Transitions
CSS3 Animations
CSS3 Buttons
CSS3 Multiple Columns
CSS3 User Interface
CSS3 Box Sizing
CSS3 Flexbox
CSS3 Filters
CSS3 Media Queries
CSS3 MQ Examples
CSS Responsive
RWD IntroRWD Viewport
RWD Grid View
RWD Media Queries
RWD Images
RWD Videos
RWD Frameworks
CSS Examples
CSS ImagesCSS Pagination
CSS Examples
CSS Quiz
CSS Certificate
CSS References
CSS ReferenceCSS Selectors
CSS Functions
CSS Reference Aural
CSS Web Safe Fonts
CSS Animatable
CSS Units
CSS PX-EM Converter
CSS Colors
CSS Color Values
CSS Color Names
CSS Color HEX
CSS Color Groups
CSS3 Browser Support
CSS3 Rounded Corners
CSS3 Rounded Corners
With the CSS3border-radius property, you can give any element "rounded corners".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- | 12.0 | 9.0 | 4.0 3.0 -moz- | 5.0 3.1 -webkit- | 10.5 |
CSS3 border-radius Property
With CSS3, you can give any element "rounded corners", by using theborder-radius property.Here are three examples:
1. Rounded corners for an element with a specified background color:
Rounded corners!
2. Rounded corners for an element with a border:Rounded corners!
3. Rounded corners for an element with a background image:Rounded corners!
Here is the code:Example
#rcorners1 {
border-radius: 25px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners2 {
border-radius: 25px;
border: 2px solid #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners3 {
border-radius: 25px;
background: url(paper.gif);
background-position: left top;
background-repeat:
repeat;
padding: 20px;
width:
200px;
height: 150px;
} Try it yourself »Tip: The border-radius property is actually a shorthand property for the border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius properties. |
CSS3 border-radius - Specify Each Corner
If you specify only one value for theborder-radius property, this radius will be applied to all 4 corners.
However, you can specify each corner separately if you wish. Here are the rules:
- Four values: first value applies to top-left, second value applies to top-right,
third value applies to bottom-right, and fourth value applies to bottom-left
corner - Three values: first value applies to top-left, second value applies to top-right and bottom-left,
and third value applies to bottom-right - Two values: first value applies to top-left and bottom-right
corner, and the second value applies to top-right and bottom-left corner - One value: all four corners are rounded equally
1. Four values - border-radius: 15px 50px 30px 5px:
2. Three values - border-radius: 15px 50px 30px:
3. Two values - border-radius: 15px 50px:
Here is the code:
Example
#rcorners4 {
border-radius: 15px 50px 30px 5px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners5 {
border-radius: 15px 50px 30px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners6 {
border-radius: 15px 50px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
} Try it yourself »You could also create elliptical corners:
Example
#rcorners7 {
border-radius: 50px/15px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners8 {
border-radius: 15px/50px;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
}
#rcorners9 {
border-radius: 50%;
background: #73AD21;
padding: 20px;
width: 200px;
height: 150px;
} Try it yourself »Test Yourself with Exercises!
Exercise 1 »Exercise 2 »
CSS3 Rounded Corners Properties
| Property | Description |
|---|---|
| border-radius | A shorthand property for setting all the four border-*-*-radius properties |
border-top-left-radius | Defines the shape of the border of the top-left corner |
border-top-right-radius | Defines the shape of the border of the top-right corner |
border-bottom-right-radius | Defines the shape of the border of the bottom-right corner |
border-bottom-left-radius | Defines the shape of the border of the bottom-left corner |
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1422003450156-5'); });
W3SCHOOLS EXAMS
HTML, CSS, JavaScript, PHP, jQuery, and XML CertificationsSHARE THIS PAGE
LEARN MORE:
Google MapsAnimated Buttons
Modal Boxes
JS Animations
Progress Bars
Dropdowns
HTML Includes
Color Palettes