border

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jul 28, 2021Updated Sep 3, 2021
Contribute to Docs

Shorthand property that sets different properties for an elements border in a single declaration.

Syntax

border: <values>;

The border property accepts one or more of the following properties as values:

  • border-style(required)
  • border-color
  • border-width

Example 1

Setting a div elements border style to dashed.

div {
/* <border-style> */
border: dashed;
}

Example 2

Setting an img elements border to dotted, red and a width of 20px.

div {
/* <border-width> | <border-style> | <border-color> */
border: 20px dotted red;
}

All contributors

Looking to contribute?

Learn CSS on Codecademy