CSS border-top-width

The border-top-width property in CSS is used to set the width of the top border of an element. This property can be specified in various units such as pixels, em, rem, percentages, etc. By default, the width of the border is set to medium.

Here's an example of how to use the border-top-width property in CSS:

Result:

This is an example text with a top border width of 2px.

In the example above, we have set the border-top-width property to 2px for the div element, which creates a top border of 2 pixels in width.

Here's the CSS code that was used to achieve the result:


div {
  border: 2px solid black;
  border-top-width: 2px;
  height: 50px;
  width: 200px;
  padding: 10px;
}

You can also specify the border-top-width using other units such as em or rem. Here's an example:

Result:

This is an example text with a top border width of 0.5em.

In this example, the border-top-width is set to 0.5em, which creates a top border that is 0.5 times the size of the font of the element.

Experiment with different values for the border-top-width property to see how it affects the top border of an element in CSS!