CSS rounded corners can be achieved using the border-radius
property. This property allows you to create rounded corners on an element’s border.
CSS provides several ways to create rounded corners for elements such as boxes, buttons, and images. Rounded corners can give a softer, more approachable look to a design, and can help break up the harshness of sharp angles and straight lines.
The border-radius
property is used to create rounded corners in CSS. It takes a value or values (in the form of a comma-separated list) that represent the radius of each corner. For example, to create rounded corners with a radius of 10 pixels for all four corners, you can use the following CSS:
border-radius: 10px;
If you want to set different radii for each corner, you can use a comma-separated list of values. The values are applied in clockwise order, starting with the top-left corner. For example, to create rounded corners with a radius of 10 pixels for the top-left corner, 20 pixels for the top-right corner, 30 pixels for the bottom-right corner, and 40 pixels for the bottom-left corner, you can use the following CSS:
border-radius: 10px 20px 30px 40px;
Alternatively, you can use the border-top-left-radius
, border-top-right-radius
, border-bottom-right-radius
, and border-bottom-left-radius
properties to set the radius for each individual corner. For example:
border-top-left-radius: 10px;
border-top-right-radius: 20px;
border-bottom-right-radius: 30px;
border-bottom-left-radius: 40px;
You can also use the border-radius
property to create elliptical or pill-shaped corners by using two values. The first value represents the horizontal radius, and the second value represents the vertical radius. For example:
border-radius: 50px 20px;
This will create rounded corners with a horizontal radius of 50 pixels and a vertical radius of 20 pixels.
In addition to the border-radius
property, there are other properties that can be used to create rounded corners. For example, the clip-path
property can be used to create complex shapes, including rounded corners. However, this property is not yet widely supported by all browsers.