CSS border-top-width: Set or Change the Width of the Top Border

The CSS border-top-width property is used when we need to define or change the width of the top border of an element. For example:

HTML with CSS Code
<!DOCTYPE html>
      h2 {border: 3px solid crimson; border-top-width: 12px; padding: 10px;}
      p {border: 3px solid palevioletred; border-top-width: 8px; padding: 10px;}

   <h2>The border-top-width Property</h2>
   <p>This is a para.</p>

The border-top-width Property

This is a para.

In the above example, the "h2" selector targets all h2 elements, whereas the "p" selector targets all p elements. Here is a description of the CSS code:

CSS border-top-width syntax

The syntax of the border-top-width property in CSS is:

border-top-width: x;

The value of x should be any of the following:

The medium is default for all.

CSS Online Test

« Previous Tutorial Next Tutorial »

Liked this post? Share it!