CSS border-top

The border-top property in CSS is used to set the style, width, and color of the top border of an element. This property is part of the border shorthand property, which allows you to set all the border properties (top, right, bottom, and left) in one declaration.

The syntax for the border-top property is as follows:


border-top: border-width border-style border-color;

Where:

Let's see an example below:

Result:
This is an example of a top border with a width of 2px, a solid style, and a red color.

In the example above, we set the border-top property to 2px solid #ff0000. This creates a top border with a width of 2 pixels, a solid style, and a red color. The content within the div element has a padding of 10 pixels to better display the border.