CSS border-top-color (Set/Change Color of Top Border)

The CSS border-top-color property is used when we need to change the color of top border. For example:

HTML with CSS Code
<!DOCTYPE html>
<html>
<head>
   <style>
      h2 {border: 10px solid gray; border-top-color: darkred;}
      p {border: 4px solid salmon; border-top-color: forestgreen;}
   </style>
</head>
<body>

   <h2>The border-top-color Property</h2>
   <p>This is a para.</p>
   
</body>
</html>
Output

The border-top-color Property

This is a para.

CSS border-top-color Syntax

The syntax of border-top-color property in CSS, is:

border-top-color: color|transparent|initial|inherit;

The color is used to specify the particular color. The transparent is used to define the transparent color. The initial is used for the default value. And inherit is used when we need to inherit the value from its parent.

CSS Online Test


« Previous Tutorial Next Tutorial »