View video tutorial

CSS Border Shorthand

CSS

It is used to shorten the code.

CSS border property

➔ The border property is a shorthand property and is used to set the following properties in order.

  • border-width
  • border-style
  • border-color

Syntax

border: border-width border-style border-color|initial|inherit;

Property values

Common Value Description
border-width Specifies the width of the border. Default value is "medium"
border-style Specifies the style of the border. Default value is "none"
border-color Specifies the color of the border. Default value is the color of the text.
initial Sets the property to its default value.
inherit The element inherits the property value from its parent element.

Example

.p1 {
  border: 1px solid red;
}
.p2 {
  border: 2px dashed black;
}
.p3 {
  border: 3px double #64070e;
}
Try it Now »

Click on the "Try it Now" button to see how it works.