CSS Borders - Detailed Overview

Introduction to CSS Borders

In CSS, the border property is used to define the border around elements. You can customize borders using various properties including width, style, and color.

Border Width

The border-width property sets the width of the border. For example:

div {
    border-width: 5px;
    border-style: solid;
    border-color: #333;
}
Border width: 5px

Border Style

The border-style property sets the style of the border. For example:

div {
    border-style: dashed;
    border-width: 2px;
    border-color: #333;
}
Border style: Dashed

Border Color

The border-color property sets the color of the border. For example:

div {
    border-color: #ff6347;
    border-style: solid;
    border-width: 4px;
}
Border color: Tomato

Border Radius

The border-radius property defines the radius of the element's corners. For example:

div {
    border-radius: 15px;
    border-style: solid;
    border-width: 3px;
    border-color: #333;
}
Border radius: 15px

Shorthand Border Property

The border shorthand property sets the border width, style, and color all at once. For example:

div {
    border: 2px solid #000;
}
Shorthand border: 2px solid black

Multiple Borders

You can create multiple borders using the border property with multiple values. For example:

div {
    border: 5px solid #ff6347;
    border: 10px double #333;
}
Multiple borders