Introduction
I strongly recommend reading the following previous parts.
- CSS3 Series Part 1: Introduction, Features, and Use of CSS3
- CSS3 Series Part 2: Playing With Backgrounds
- CSS3 Series Part 3: Multi-Column Layout with CSS3

This article explains the various kinds of borders in CSS3 and we'll also see some of the border styles in CSS.

- Border-radius
- Box-shadow
- Border-image
Using CSS3, you can create Rounded borders, you can add shadow to your elements, you can even use an image as a border.
In this article, we'll see the "Border-radius" and "Box-shadow" properties.
Border Radius
First, we'll explain border-radius. If you see in the previous versions of CSS (CSS1 and CSS2.0), we didn't have an option to create such rounded borders; it was very difficult to create a rounded border for any element.
But in CSS3, creating rounded borders is as simple as creating any normal border. We'll start creating rounded borders for each side and finally, we'll use shorthand property to create rounded borders for all sides within one line.
First, we'll create a box with a 5px border, font size of 25px, Gray type background color and some other styles as shown in the following example.
- div
- {
- background-color:#f2f2f2;
- height:auto;
- width:80%;
- font-weight:bold;
- font-size:25px;
- text-align:center;
- padding:20px;
- border:5px solid #333;
- }

- .topLeft
- {
- border-top-left-radius:25px;
- }

- .topRight
- {
- border-top-right-radius:25px;
- }

- .bottomLeft
- {
- border-bottom-right-radius:25px;
- }

- .bottomLeft
- {
- border-bottom-left-radius:25px;
- }

- .roundedBorder
- {
- border-radius:25px;
- }

- border-radius : top_left_px top_right_px bottom_right_px bottom_left_px.
For example we'll create a rounded border for a div element, like 50px from the top-left, 40xpx from the top-right, 30px from the bottom-right, 20px from the bottom-left as shown below.
- .cocktail
- {
- border-radius:50px 40px 30px 20px;
- }

- box-shadow: [Horizontal Offset], [Vertical Offset], [Blur Radius], [Spread Radius], [Color];
| Name | Description |
| Horizontal Offset
|
Drop horizontal shadow, positive value for right shadow and negative for left |
| Vertical Offset | Drop vertical shadow, positive value for the following shadow and negative for the preceding |
| Blur Radius | Set the blur amount for shadow, 0 for sharp and higher the value, more blurred shadow |
| Spread Radius | Set the size of the shadow, positive for more shadow, negative for less |
| Color | Name of the color for the shadow |
- div
- {
- height:100px;
- width:600px;
- background-color:goldenrod;
- border: 2px solid #333;
- font-size: 35px;
- text-align:center;
- font-weight:bold;
- }
- <div> Normal Box without Shadow. </div>
This will create a normal box as shown below.
Now we'll drop various kinds of shadows with the code + output as shown below.

- .horizontalShadow
- {
- box-shadow: 20px 0px 20px 1px #333;
- }

- .verticalShadow
- {
- box-shadow: 0px 20px 20px 1px #333;
- }

- .leftHorizontalShadow
- {
- margin-left: 100px;
- box-shadow: -20px 0px 20px 1px #333;
- }

- .blurWith50px_and_10px_spread_radius
- {
- box-shadow: 7px 10px 50px 10px #333;
- }

- .blurWith5px_and_5px_spread_radius
- {
- box-shadow: 7px 10px 5px 5px #333;
- }


Tom MohanPosted Mar 23, 2015, 8:20 PM
colorful. nice
Manish Kumar ChoudharyPosted Mar 23, 2015, 4:20 AM
Nice one.