Code has been added to clipboard!

The CSS Border-Radius Property

Reading time 2 min
Published Aug 8, 2017
Updated Oct 1, 2019

Understanding CSS border-radius

By using the CSS border-radius property, you can define rounded corners for an element:

Example
div {
    border: 3px solid;
    border-radius: 30px;
}

It is actually a shorthand for four CSS border radius subproperties:

  • border-top-left-radius
  • border-top-right-radius
  • border-bottom-left-radius
  • border-bottom-right-radius

Each of these subproperties could be used to style each corner individually:

Example
div {
    border: 4px solid green;
    border-top-left-radius: 4em;  	
}
Example
div {
    border: 4px solid green;
    border-top-right-radius: 4em;
}

If you add rounded corners for an element that has a background color or a background image, it will be rounded with the border as well and not leak over its lines:

Example
#roundcorners {
    border-radius: 30px;
    background: url(sheet.gif);
    background-position: center top;
    background-repeat: repeat;
    padding: 25px; 
    width: 250px;
    height: 200px; 
}

Syntax for CSS border-radius

The syntax for border-radius is simple:

border-radius: value1 value2 value3 value4;

The values can be defined in either length units or percentages. You can specify one, two, three, or four of them:

Syntax Example Explanation
One value border-radius: 3px; All four corners are modified in the same manner.
Two values border-radius: 3px 6px; The first value is used to modify the top left and the bottom right corners.
The second value is used to modify the top right and the bottom left corners.
Three values border-radius: 3px 6px 9px; The first value is used to modify the top left corner.
The second value is used to modify the top right and the bottom left corners.
The third value is used to modify the bottom right corner.
Four values border-radius: 3px 6px 9px 12px; The first value is used to modify the top left corner.
The second value is used to modify the top right corner.
The third value is used to modify the bottom right corner.
The fourth value is used to modify the bottom left corner.

Ellipse corners with border-radius

In some cases, you might not need the corners to be perfectly round. To create elliptical rounding, define two values for the CSS border-radius property and put a slash (/) between them. The first value will specify the horizontal radius for the corner, and the second one will define the vertical radius:

Example
#example1 {
    border: 5px solid green;
    padding: 10px;
    border-radius: 3em;
}

#example2 {
    border: 5px solid red;
    padding: 10px;
    border-radius: 3em/6em;
}

Browser support

Chrome
4+
Edge
12+
Firefox
4+
IE
9+
Opera
10.5+
Safari
5+

Mobile browser support

Chrome
18+
Firefox
4+
Opera
11+
Safari
All
Tutorial
CSS3 Features
Syntax
Classes
ID Selectors
Attribute Selectors
Stylesheets
Inline
Internal
External
Box Model
Children Selectors
Pseudo Classes
Pseudo Elements
Variables
Counters
Text
Fonts
Web Fonts
Backgrounds
Background Images
Colors
Gradients
Opacity / Transparency
Shadow Effects
Transitions
Tooltip
Transform
Animations
Layout — Display
Layout — Position
Layout — Float
Layout — Clear
Layout — Horizontal & Vertical Align
Multiple Columns
Introduction
Responsive Web Design — Viewport
Responsive Web Design — Grid View
Responsive Web Design — Media Queries
Responsive Web Design — Flexbox Layout
Responsive Web Design — Images
Responsive Web Design — Videos
Borders
Margin
Padding
Width
Height
Outline
Links
Lists
Tables
Dropdown Menu
Navigation Bar
Images
Image Gallery
Border Images
Forms
Rounded Corners
Buttons
Box-Sizing
Selector Reference
Pagination Examples
Code Examples
CSS3 Browser Support Reference
Functions Reference
Speech Module Reference
Units
Web Safe Font Combinations
Cheat Sheet
:hover
@font-face
@keyframes
@media
align-content
align-items
align-self
all
animation
backface-visibility
background
background-clip
background-color
background-image
background-origin
background-position
background-size
border
border-image
border-radius
border-style
box-shadow
box-sizing
color
columns
filter
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-weight
hanging-punctuation
justify-content
line-height
margin
offset
opacity
order
outline
overflow
padding
perspective
position
resize
tab-size
text-align
text-decoration
text-emphasis
text-transform
text-shadow
transform
transition-property
translate
vertical-align
word-break
word-wrap
z-index