What is the CSS border-top property?

The border-top property in CSS is used to define the properties of the top in one line. This property is used to define the color, style, and width of the top border.

It is a shorthand property of the following:

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

The border-top-style is compulsory to define.

Syntax

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

Property values

  • border-top-width: This is used to specify the width of the border. Medium is the default value.

  • border-top-style: This has a default value of NULL. It is used to set the style of the border.

  • border-top-color: This is used to set the color of the border.

  • initial: This is used to set the value to its default value.

  • inherit: This is used to inherit property from its parent value.

Code

In the code above, the border-top property of class .bdr has been set to 25px width, solid style, and skyblue color.

Free Resources