CSS | currentcolor keyword

The CSS currentcolor keyword is used to define the color but use the currently used color property. If you want to use the same color at multiple places then you can easily use currentcolor keyword. Just you have to set a color property after that you can easily use currentcolor that will set the color for all the other places where you want to set them. So in future, if you want to change all the color then you need to change color in one place.
Syntax:

background-color: currentcolor;

Example 1: In this example we will use currentcolor for box-shadow.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
    <title>
        CSS currentcolor keyword
    </title>
    <style>
        body {
            color: green;
            font-size: 1.2em;
        }
          
        div {
            box-shadow: 0px 0px 80px currentcolor;
            border: 10px solid;
            width: 50%;
            margin: auto;
            padding: 20px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
  
        <div>
            A Computer Science Portal
        </div>
    </center>
</body>
</html>

chevron_right


Output:



Example 2: Text Color on Backgrounds with currentcolor.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<title>CSS currentcolor keyword</title>
  
<head>
    <style>
        body {
            color: green;
        }
          
        div {
            background: currentcolor;
            width: 60%;
            margin: auto;
            padding: 5px 20px;
        }
          
        div > p {
            color: white;
            opacity: 0.5;
            font-size: 1.5em;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <div>
            <p>A Computer Science Portal</p>
        </div>
    </center>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by CSS currentcolor keyword are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.