aboutsummaryrefslogtreecommitdiff
path: root/posts/current-color.md
blob: 3cad2ff1bc89faee478e0af766baac75d8f6a35d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# CSS Value: `currentColor`

2019-04-13

*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:

```css
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:

```css
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!