The border properties allow you to specify how the border of the box representing an element should look. There are three properties of a border you can change:
The border-color specifies the color of a border.
The border-style specifies whether a border should be solid, dashed line, double line, or one of the other possible values.
The border-width specifies the width of a border.
CSS Border Properties
The border-color property allows you to change the color of the border surrounding an element. You can individually change the color of the bottom, left, top and right sides of an element's border using the properties −
border-bottom-color changes the color of bottom border.
border-top-color changes the color of top border.
border-left-color changes the color of left border.
border-right-color changes the color of right border.
Border Style
The border-style property specifies what kind of border to display.
The following values are allowed:
dashed - Defines a dashed border
dotted - Defines a dotted border
solid - Defines a solid border
double - Defines a double border
groove - Defines a 3D grooved border. The effect depends on the border-color value
inset - Defines a 3D inset border. The effect depends on the border-color value
ridge - Defines a 3D ridged border. The effect depends on the border-color value
outset - Defines a 3D outset border. The effect depends on the border-color value
none - Defines no border
hidden - Defines a hidden border
The border-style property can have from one to four values (for the top border, right border, bottom border, and the left border).
Example -
Border Width
The border-width property allows you to set the width of an element borders. The value of this property could be either a length in px, pt or cm or it should be set to thin, medium or thick.
You can individually change the width of the bottom, top, left, and right borders of an element using the following properties −
border-bottom-width changes the width of bottom border.
border-top-width changes the width of top border.
border-left-width changes the width of left border.
border-right-width changes the width of right border.
Example -
Border Color
The border-color property is used to set the color of the four borders.
The color can be set by:
name - specify a color name, like "red"
Hex - specify a hex value, like "#ff0000"
RGB - specify a RGB value, like "rgb(255,0,0)"
transparent
The border-color property can have from one to four values (for the top border, right border, bottom border, and the left border).
Example -
Border - Individual Sides
From the examples above you have seen that it is possible to specify a different border for each side.
Example -
Border - Shorthand Property
As you can see from the examples above, there are many properties to consider when dealing with borders.To shorten the code, it is also possible to specify all the individual border properties in one property.The border property is a shorthand property for the following individual border properties:
border-width
border-style (required)
border-color
Example -
Left Border
Example -
Bottom Border
Example -
Rounded Borders
The border-radius property is used to add rounded borders to an element: