CSS value: current color

There are a large number of nuanced and mostly unheard of CSS value types, but today we are going to focus on currentColor. So what is the currentColor value type anyway?

The currentColor value type will apply the existing color value to other prop…


This content originally appeared on Ugly Duck and was authored by Bradley Taunt

There are a large number of nuanced and mostly unheard of CSS value types, but today we are going to focus on currentColor. So what is the currentColor value type anyway?

The currentColor value type will apply the existing color value to other properties like background-color, etc.

See it in action

Let’s assume with have a single div with the following properties:

div {
    color: dodgerblue;
}

If we wanted to use that same color for other properties on elements inside that initial div, it’s simple - we just need to call currentColor like so:

div {
    color: dodgerblue;
}

div header {
    background-color: currentColor;
}

div a {
    border-bottom: 1px solid currentColor;
}

Sidenote: If you re-declare the default color property further along in your CSS, the currentColor value will update according to the last color set.

And that’s it. Best of all, this value type is supported across all major browsers!


This content originally appeared on Ugly Duck and was authored by Bradley Taunt


Print Share Comment Cite Upload Translate Updates
APA

Bradley Taunt | Sciencx (2019-04-13T00:00:00+00:00) CSS value: current color. Retrieved from https://www.scien.cx/2019/04/13/css-value-current-color/

MLA
" » CSS value: current color." Bradley Taunt | Sciencx - Saturday April 13, 2019, https://www.scien.cx/2019/04/13/css-value-current-color/
HARVARD
Bradley Taunt | Sciencx Saturday April 13, 2019 » CSS value: current color., viewed ,<https://www.scien.cx/2019/04/13/css-value-current-color/>
VANCOUVER
Bradley Taunt | Sciencx - » CSS value: current color. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2019/04/13/css-value-current-color/
CHICAGO
" » CSS value: current color." Bradley Taunt | Sciencx - Accessed . https://www.scien.cx/2019/04/13/css-value-current-color/
IEEE
" » CSS value: current color." Bradley Taunt | Sciencx [Online]. Available: https://www.scien.cx/2019/04/13/css-value-current-color/. [Accessed: ]
rf:citation
» CSS value: current color | Bradley Taunt | Sciencx | https://www.scien.cx/2019/04/13/css-value-current-color/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.