Border Radius Property In CSS

Border Radius Property In CSS

How to make rounded corners in css?

Css Border Radius Property with an Example
Border Radius Property in CSS to round the corner of an element.


border-radius is one of the properties of CSS. It is used to round the corner of an element.

Now, let’s see how to use it.

Usage

border-radius property can have one to four values.

1)border-radius with four values.

If border-radius property contains four values. then,
– the first value applies to top-left corner of an element
– second value applies to top-right corner of an element
– the third value applies to bottom-right corner of an element
– fourth value applies to bottom-left corner of an element.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br />         border-radius:10px 20px 30px 40px; <br />         background: #e92138; <br />         padding: 30px; <br />         text-align:center; <br />         width: 250px; <br />         height: 140px; <br />         color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-radius: 10px 20px 30px 40px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Radius Element

border-radius: 10px 20px 30px 40px;

Following are the values for the corner radius for the above border-radius value.

Corner Value
Top Left 10px
Top Right 20px
Bottom Right 30px
Bottom Left 40px

2) border-radius with three values.

If border-radius property contains three values. then,
– the first value applies to top-left corner of an element
– second value applies to top-right and bottom-left corner of an element
– the third value applies to bottom-right corner of an element.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br />         border-radius:10px 20px 30px; <br />         background: #e92138; <br />         padding: 30px; <br />         text-align:center; <br />         width: 250px; <br />         height: 140px; <br />         color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-radius: 10px 20px 30px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Radius Element

border-radius: 10px 20px 30px;

Following are the values for the corner radius for the above border-radius value.

Corner Value
Top Left 10px
Top Right 20px
Bottom Right 30px
Bottom Left 20px

3) border-radius with two values.

If border-radius property contains two values. then,

– the first value applies to top-left and bottom-right corner of an element
– second value applies to top-right and bottom-left corner of an element.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br />         border-radius:10px 20px; <br />         background: #e92138; <br />         padding: 30px; <br />         text-align:center; <br />         width: 250px; <br />         height: 140px; <br />         color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-radius: 10px 20px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Radius Element

border-radius: 10px 20px;

Following are the values for the corner radius for the above border-radius value.

Corner
Value
Top Left
10px
Top Right
20px
Bottom Right
10px
Bottom Left
20px

4) border-radius with one values.

If border-radius property contains one value. then,

– the first value applies to all corners of an element.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br />         border-radius:10px; <br />         background: #e92138; <br />         padding: 30px; <br />         text-align:center; <br />         width: 250px; <br />         height: 140px; <br />         color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-radius: 10px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Radius Element

border-radius: 10px;

Following are the values for the corner radius for the above border-radius value.

Corner Value
Top Left 10px
Top Right 10px
Bottom Right 10px
Bottom Left 10px

There are also other  properties available for each corner.

1) border-top-left-radius: 

This property can be used to set the value for top-left corner.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Top Left Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br /> border-top-left-radius: 40px; <br /> background: #e92138; <br /> padding: 30px; <br /> text-align:center; <br /> width: 250px; <br /> height: 140px; <br />       color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Top Left Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-top-left-radius: 40px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Top Left Radius Element

border-top-left-radius: 40px;

2) border-top-right-radius: 

This property can be used to set the value for top-left corner.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Top Right Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br /> border-top-right-radius: 40px; <br /> background: #e92138; <br /> padding: 30px; <br /> text-align:center; <br /> width: 250px; <br /> height: 140px; <br />       color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Top Right Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-top-left-radius: 40px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Top Right Radius Element

border-top-right-radius: 40px;

3) border-bottom-left-radius: 

This property can be used to set the value for top-left corner.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Bottom Left Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br /> border-bottom-left-radius: 40px; <br /> background: #e92138; <br /> padding: 30px; <br /> text-align:center; <br /> width: 250px; <br /> height: 140px; <br />       color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Bottom Left Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-bottom-left-radius: 40px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Bottom Left Radius Element

border-bottom-left-radius: 40px;

4) border-bottom-right-radius: 

This property can be used to set the value for top-left corner.

&lt;!DOCTYPE html&gt; <br />&lt;html&gt; <br />  &lt;head&gt; <br />  &lt;title&gt;Border Bottom Right Radius Example&lt;/title&gt; <br />  &lt;style&gt; <br />     .border-radius-element { <br /> border-bottom-right-radius: 40px; <br /> background: #e92138; <br /> padding: 30px; <br /> text-align:center; <br /> width: 250px; <br /> height: 140px; <br />       color:#fff<br />     } <br />  &lt;/style&gt; <br />  &lt;/head&gt; <br />&lt;body&gt; <br />&lt;div class="border-radius-element"&gt; <br />     &lt;h2&gt;Border Bottom Right Radius Element&lt;/h2&gt; <br />     &lt;p&gt;border-top-left-radius: 40px;&lt;/p&gt;&lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br /><br />

Output

Border Bottom Right Radius Element

border-bottom-right-radius: 40px;

Also, read:

Leave a Comment