CSS border-radius Property
Last Updated :
10 Oct, 2024
The CSS border-radius property allows you to round the corners of an element’s outer border, giving it a smooth, curved appearance. You can specify one, two, three, or four values to individually control the radius of each corner. By using this property, you can create visually appealing designs, such as circles or rounded buttons.
However, it’s important to note that the border-radius property does not work on table elements when the border-collapse property is set to collapse, as the borders are treated differently in that case.
Syntax
border-radius: 1-4 length|% / 1-4 length|%|initial|inherit;
Property Values
Property Value | Description |
---|
length | Represents the shape of the corners, typically in units like px , em , or rem . The default value is 0 . |
percentage (%) | Represents the shape of the corners in percentage, where the rounding is relative to the element’s size. |
initial | Resets the element’s CSS property to its default value. |
inherit | Inherits the property value from the parent element. |
Shorthand Notations for border-radius
- Apply Radius value to all four corners:
border-radius: value;
- Apply value1 to top-left and bottom-right corners and value2 to top-right and bottom-left corners:
border-radius: value1 value2;
- Apply value1 to top-left corner, value2 to top-right and bottom-left corners and value3 to bottom-right corner:
border-radius: value1 value2 value3;
- Apply value1 to top-left corner, value2 to top-right corner , value3 to bottom-right corner and value4 to bottom-left corner:
border-radius: value1 value2 value3 value4;
The 4 values for each radius can be specified in the following order as top-left, top-right, bottom-right, bottom-left. If the bottom-left is removed then it will be the same as the top-right. Similarly, If the bottom-right & top-right will be removed then it will be the same as the top-left & the top-left respectively.
CSS Border Radius Examples
border-radius: 35px; sets the border-radius of each corner. It is the combination of four properties: border-top-left-radius, border-top-right-radius, border-bottom-left-radius, and border-bottom-right-radius. It sets all corners to the same value.
Example 1: Rounded Corneers for all Sides
This example demonstrates how the border-radius property is applied to round the corners of an element. The border-radius: 35px; value rounds all four corners of the green box uniformly, giving it smooth, curved edges. The element is styled with padding, a fixed width, and height, along with centered text.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Rounded Corners</title>
<style>
.GFG {
border-radius: 35px;
background: #009900;
padding: 30px;
text-align: center;
width: 300px;
height: 120px;
}
</style>
</head>
<body>
<div class="GFG">
<h2>GeeksforGeeks</h2>
<p>border-radius: 35px;</p>
</div>
</body>
</html>
Output:

border-radius: 20px 40px; sets first value as top-left and bottom right corner and second value as top right and bottom left corners.
Example 2: Rounded Corners with Two Values
In this example, the border-radius property is set to two values, 20px 40px. The first value (20px) applies to the top-left and bottom-right corners, while the second value (40px) applies to the top-right and bottom-left corners. This results in asymmetrical rounded corners, creating a unique design for the element. The element also has padding, a fixed width, and height, with centered text.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Rounded Corners</title>
<style>
.GFG {
border-radius: 20px 40px;
background: #009900;
padding: 30px;
text-align: center;
width: 300px;
height: 120px;
}
</style>
</head>
<body>
<div class="GFG">
<h2>GeeksforGeeks</h2>
<p>border-radius: 20px 40px;</p>
</div>
</body>
</html>
Output:

Example 3: Rounded Top-Left Corner
In this example, the border-top-left-radius property is applied to round only the top-left corner of the element with a value of 35px. The other corners remain unchanged, creating a smooth curve on the top-left side while the rest of the box retains sharp edges. The element is styled with padding, a fixed width, and height, with centered text.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Rounded Corners</title>
<style>
.GFG {
border-top-left-radius: 35px;
background: #009900;
padding: 30px;
text-align: center;
width: 300px;
height: 120px;
}
</style>
</head>
<body>
<div class="GFG">
<h2>GeeksforGeeks</h2>
<p>border-top-left-radius: 35px;</p>
</div>
</body>
</html>
Output:

Supported Browsers
- Google Chrome 4.0
- Internet Explorer 9.0
- Microsoft Edge 12.0
- Firefox 4.0
- Opera 10.5
- Safari 5.0
Note: The border-radius
property is widely supported across all major browsers, starting from the versions listed above.
Similar Reads
CSS @charset Rule
The @charset rule specifies the character encoding used in the style sheet. The @charset must be the first element in the style sheet and if several @charset rules are defined then the only first one is used. It can not be used in the <style> element where the character set of the HTML page is
3 min read
CSS @keyframes Rule
The CSS @keyframes rule defines animations by specifying keyframes that describe the styles to be applied at various points during the animation duration. It allows for smooth transitions and transformations in web elements, controlled through percentages or from-to values. Note:For optimal browser
3 min read
CSS @media Rule
The @media CSS at-rule is used to apply a different set of styles for different media/devices using the Media Queries. A Media Query is mainly used to check the height, width, resolution, and orientation(Portrait/Landscape) of the device. This CSS rule is a way out for making more out of responsive
5 min read
CSS align-content property
The align-content property changes the behavior of the flex-wrap property. It aligns flex lines. It is used to specify the alignment between the lines inside a flexible container. This property defines how each flex line is aligned within a flexbox and is only applicable if flex-wrap: wrap is applie
5 min read
CSS align-items Property
The align-items property in CSS is used to align flex items along the cross-axis within a flex container. It accepts values like flex-start, flex-end, center, baseline, and stretch, controlling the vertical alignment of items in a flexbox. Syntaxalign-items: normal | stretch | center | flex-start |
7 min read
CSS align-self Property
The align-self property in CSS is used to align the selected items in the flexible container in many different manners such as flex-end, center, flex-start, etc. Syntax: align-self: auto|normal|self-start|self-end|stretch|center |baseline, first baseline, last baseline|flex-start |flex-end|baseline
5 min read
CSS all Property
The all property in CSS is the shorthand property used to set all the element's values to their initial or inherited values or in some cases used to set the values to another spreadsheet origin. This property is used to reset all the CSS properties in a document. Syntax:Â all: initial|inherit|unset|
3 min read
CSS animation-delay Property
The animation-delay property specifies a delay for the start of an animation. Defined in seconds (s) or milliseconds (ms), this value determines how long to wait before beginning the animation. Negative values start the animation as if it had already been playing for the specified duration. Syntaxan
3 min read
CSS animation-direction Property
The animation-direction CSS property sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward. It controls the visual flow and repetition behavior of animations in web pages, enhancing dynamic content presentation. Syntaxa
4 min read
CSS animation-duration Property
The animation-duration property in CSS is essential for controlling the length of time an animation takes to complete one cycle, making it a vital tool for creating dynamic and engaging web designs. Syntax:animation-duration: time | initial | inherit;Property Value:time: This value is used to specif
3 min read