CSS Color Keywords

CSS Color Keywords


CSS Color Keywords
Here in this section we will discuss the color property value keywords.
There are three keywords we will see in this part here - 
  1. CurrentColor
  2. Transparent, and
  3. Inherit 
CurrentColor - 
The color property controls the element's text color (and text decorations such as underlines).
It also sets the current color. 
This is a special value called currentColor that resolves to the text color, which can be referenced from other properties. 
currentColor is also the default border color, if one is not specified.
Now  we'll an example - 
Example - The color value and currentColor property
class="one">One
 
class="two">Two
Output - 
Explanation  - 
In the above example, we gave one element a color of red and the other a color of blue. 
This sets the currentColor value of each element. Then, we also had a rule that selected both div elements and used the currentColor as the border color. 
The red div gets a red border, and the blue div gets a blue border.
Transparent -
The transparent keyword is used to make the background color of an element transparent.
Now we will see an example - 
Example - 
Output - 
Explanation -
Here we can see the second div has no color that is because we used transparent.
inherit Keyword - 
Inherit keyword is used when we want to use parent elements property in the chile element like -  color etc.
We can also use it for any other property as well.
Now we will see example - 
Example - 
Output-