Easy Rounded Corners using CSS3
Syntax
border-radius: 12px;
}
Sample in action

Source Code
- <!DOCTYPE html>
- <head>
- <style>
- #roundcnr1
- {
- -moz-border-radius: 12px;
- border-radius:
- 12px;
- border-style: solid;
- border-color: #996600;
- border-width: 1px;
- }
- </style>
- </head>
- <body>
- Div without
- Rounded corners
- <BR/>
- <br/>
- <div style="border: 1px solid
- black;width:100px;" >
- Hello - without rounded borders
- </div>
- <BR/>
- Div with Rounded
- corners
- <br/>
- <BR/>
- <div style="border: 1px solid
- black;border-radius:10px;width:100px;" >
- Hello - with rounded borders
- </div>
- <BR/>
- Table without Rounded corners
- <br/>
- <BR/>
- <table
- style="border: 1px solid black;">
- <tr>
- <td>Row1 Col1
- </td>
- <td>Row1 Col2
- </td>
- </tr>
- <tr>
- <td>Row2 Col1
- </td>
- <td>Row2 Col2 </td>
- </tr>
- </table>
- <BR/>
- Table with Rounded corners
- <br/>
- <BR/>
- <table
- style="border: 1px solid
- black;border-radius:4px">
- <tr>
- <td>Row1 Col1
- </td>
- <td>Row1 Col2
- </td>
- </tr>
- <tr>
- <td>Row2 Col1
- </td>
- <td>Row2 Col2 </td>
- </tr>
- </table>
- <br/>
- </body>
Additional Customizations
An alternative syntax would be a shorthand
H=Horizontal radius, V=Vertical radius)
border-radius: HTL HTR HBL HBR / VTL VTR VBL VBR
- border-radius: 2px 5px 3px 1px / 7px 4px 17px 6px;

- Table2 with Rounded corners
- <br/>
- <BR/>
- <table
- style="border: 1px solid black;border-radius: 2px 5px 3px 1px / 7px 4px 17px
- 6px;">
- <tr>
- <td>Row1 Col1 </td>
- <td>Row1 Col2
- </td>
- </tr>
- <tr>
- <td>Row2 Col1
- </td>
- <td>Row2 Col2 </td>
- </tr>
- </table>
Units: The units can be specified as length (px) or percentage can be used.
In this article, we saw how easy it is to render custom rounded corners using a
single css3 property. We took a look at the power and flexibility of the border-radius.
Happy Coding!
Join the conversation! Your thoughts help the community grow.