
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - border-radius Property
CSS border-radius property is used to make the corners of the outer border of an element, rounded. It is a shorthand property for the properties border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius. Depending on the number of values provided (one to four) to the property, the different portions are rounded.
Syntax
border-radius: length | percentage | initial | inherit;
Property Values
Value | Description |
---|---|
length | It specifies the roundness of the corners in length units (eg.10px 20px). Default is 0. |
percentage | It specifies the roundness of the corners in percentage (eg. 10% 20%). |
initial | It sets the property to its default value. |
inherit | It inherits the property from the parent element. |
Examples of CSS Border Radius Property
The following examples explain the border-radius property with different values.
Border Radius Property with Length Values
To define the roundness of the corners of the outer border of an element, we can specify the radius in length values (eg. 10px 20px 30px 2px, 25px 40px etc.). The property depends on the number of values passed. The following example shows this by taking different number of values.
Example
<!DOCTYPE html> <html> <style> .container { box-shadow: 10px 10px 10px grey; display: grid; justify-items: center; align-items: center; padding: 20px; margin-bottom: 20px; } .box { height: 50px; width: 50px; padding: 10%; border: 1px solid grey; background-color: lightgreen; } #one { border-radius: 20px; } #two { border-radius: 15px 50px; } #three { border-radius: 15px 45px 90px; } #four { border-radius: 15px 45px 75px 10px; } </style> <head> </head> <body> <h2> CSS border-radius property </h2> <div class="container"> <p> This box uses a single value 20px for the border-radius property. So all the four corners top-left, top-right, bottom-right and bottom-left have the same radius corners as shown here.</p> <p id="one" class="box"> 20px </p> </div> <div class="container"> <p> This box uses two values 15px 50px for the border-radius property. top-left and bottom-rigth corners have 15px radius while top-right and bottom-left have 50px radii corners as shown here. </p> <p id="two" class="box"> 15px 50px </p> </div> <div class="container"> <p> This box uses three values 15px 45px 90px for the border-radius property. top-left has 15px radius, top-right and bottom-left have 45px radius and bottom-right has 90px radius as shown here. </p> <p id="three" class="box"> 15px 45px 90px </p> </div> <div class="container"> <p> This box uses four values 15px 45px 75px 10px for the border-radius property. top-left has 15px radius, top-right has 45px, bottom-right has 75px and bottom-left has 10px radii corners as shown here. </p> <p id="four" class="box"> 15px 45px 75px 10px </p> </div> </body> </html>
Border Radius Property with Percentage Values
To define the roundness of the corners of the outer border of an element, we can specify the radius in percentage values (eg. 10% 20% 30% 2%, 25% 40% etc.). The property depends on the number of values passed. The following example shows this by taking different number of values.
Example
<!DOCTYPE html> <html> <style> .container { box-shadow: 10px 10px 10px grey; display: grid; justify-items: center; align-items: center; padding: 20px; margin-bottom: 20px; } .box { height: 50px; width: 50px; padding: 10%; border: 1px solid grey; background-color: lightblue; } #one { border-radius: 20%; } #two { border-radius: 15% 50%; } #three { border-radius: 15% 45% 90%; } #four { border-radius: 15% 45% 75% 10%; } </style> <head> </head> <body> <h2> CSS border-radius property </h2> <div class="container"> <p> This box uses a single value 20% for the border-radius property. So all the four corners top-left, top-right, bottom-right and bottom-left have the same radius corners as shown here. </p> <p id="one" class="box"> 20% </p> </div> <div class="container"> <p> This box uses two values 15% 50% for the border-radius property. top-left ad bottom-rigth corners have 15% radius while top-right and bottom-left have 50% radii corners as shown here. </p> <p id="two" class="box"> 15% 50% </p> </div> <div class="container"> <p> This box uses three values 15% 45% 90% for the border-radius property. top-left has 15% radius, top-right and bottom-left have 45% radius and bottom-right has 90% radius as shown here. </p> <p id="three" class="box"> 15% 45% 90% </p> </div> <div class="container"> <p> This box uses four values 15% 45% 75% 10% for the border-radius property. top-left has 15% radius, top-right has 45%, bottom-right has 75% and bottom-left has 10% radii corners as shown here. </p> <p id="four" class="box"> 15% 45% 75% 10% </p> </div> </body> </html>
Border Radius Property with Mixed Values
To define the roundness of the corners of the outer border of an element, we can specify the radius in combination of length and percentage values (eg. 10px 20%, 15px 40% etc.). The following example shows this.
Example
<!DOCTYPE html> <html> <style> .container { display: grid; justify-items: center; align-items: center; padding: 20px; margin-bottom: 20px; } .box { height: 50px; width: 50px; padding: 10%; border: 1px solid grey; background-color: lightpink; } #one { border-radius: 15px 40%; } </style> <head> </head> <body> <h2> CSS border-radius property </h2> <div class="container"> <p> This box uses a combination of length and percentage values. top-left and bottom-right corners are given 15px radii while top-right and bottom-left are given with 40% radii as shown here. </p> <p id="one" class="box"> 15px 40% </p> </div> </body> </html>
Note: The border-radius property accepts upto four values, so depending on the number of values given, the corners will be rounded accordingly.
- One Value: if single value is given, it will be applied to top-left, top-right, bottom-right and bottom-left corners.
- Two Values: if two values are given, first value will be applied to top-left and bottom-right and the second value will be applied to top-right and bottom-left corners.
- Three Values: if three values are given, first value will be applied to top-left, second value to top-right and bottom-left corners and the last value will be applied to bottom-right corner.
- Four Values: if four values are given, first value will be applied to top-left, second vaue to top-right, third value to bottom-right and fourth value to bottom-left corners.
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
border-radius | 5.0 | 9.0 | 4.0 | 5.0 | 10.5 |