Easy Tutorial
❮ Css3 Box Sizing Css3 Images ❯

CSS3 Border

CSS3 Border

With CSS3, you can create rounded borders, add shadow boxes, and use images as borders without needing design programs like Photoshop.

In this chapter, you will learn about the following border properties:


CSS3 Rounded Corners

Adding rounded corners was tricky in CSS2. We had to use different images for each corner.

In CSS3, it's easy to create rounded corners.

The border-radius property in CSS3 is used to create rounded corners:

Example

Add rounded corners to a div element:

div {
    border: 2px solid;
    border-radius: 25px;
}

CSS3 Box Shadow

The box-shadow property in CSS3 is used to add shadows:

Example

Add the box-shadow property to a div element:

div {
    box-shadow: 10px 10px 5px #888888;
}

CSS3 Border Image

With the border-image property in CSS3, you can use an image to create a border:

Create a border using an image in a div:

Example

Create a border using an image in a div:

div {
    border-image: url(border.png) 30 30 round;
    -webkit-border-image: url(border.png) 30 30 round; /* Safari 5 and older */
    -o-border-image: url(border.png) 30 30 round; /* Opera */
}

New Border Properties

Property Description CSS
border-image A shorthand property for setting all the border-image-* properties. 3
border-radius A shorthand property for setting all the four border-*-radius properties. 3
box-shadow Attaches one or more drop-shadows to the box. 3
❮ Css3 Box Sizing Css3 Images ❯