Open In App

How to define the color of the border using CSS ?

We can give the color of the border using border or border-color properties. We need to give border-style property.

Approach 1: 



Example: In this example, we are using the above-explained approach.




<!DOCTYPE html>
<html>
<body>
    <h1 style="border: rgb(195, 255, 0);
            border-style: solid;">
        Java GFG
    </h1>
    <h2 style="border: rgb(0, 140, 255);
            border-style: solid;">
        C++ GFG
    </h2>
</body>
</html>

Output :



Approach 2: 

Example: In this example, we are using the above-explained approach.




<!DOCTYPE html>
<html>
<head>
    <style>
        h3 {
            border-color: rgb(0, 255, 76);
            border-style: dashed;
        }
 
        h2 {
            /* top->red right->blue bottom->green left->orange */
            border-color: red blue green orange;
            border-style: solid;
        }
 
        h1 {
            /* top/bottom ->red  left/right->blue */
            border-color: red blue;
            border-style: solid;
        }
    </style>
</head>
 
<body>
    <h1>Java GFG</h1>
    <h2>C++ GFG</h2>
    <h3>Python GFG</h3>
</body>
</html>

Output :

border-color CSS


Article Tags :