Open In App
Related Articles

CSS | currentcolor keyword

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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.
<!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>

                    
Output: Example 2: Text Color on Backgrounds with currentcolor.
<!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>

                    
Output: Supported Browsers: The browsers supported by CSS currentcolor keyword are listed below:
  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 23 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads