Reputation:
Why is the word "exemple" black here
<div style="color: red"><a href="http://exemple.com">Exemple</a></div>
while it becomes red here
<div style="color: red"><p>Exemple</p></div>
and even here
<div style="color: red"><a>Exemple</a></div>
Maybe there is a problem with 'href' attribute ?
PS : I know, that I can directly style an <a>
tag, but I think my question is still interesting.
Upvotes: 1
Views: 92
Reputation: 53
a
does not inherit it's color from its parent. You have to style it directly, either through a {color:red;}
or <a style="color: red">
Upvotes: -1
Reputation: 943615
The browser provides a default stylesheet.
In that stylesheet, the default value for the color
property on an a
element is a shade of blue, not inherit
. You haven't done anything to override the value of the color
property for the a
element.
The default value for the property on the p
element is inherit
, so it pulls in the colour from its parent element.
Upvotes: 2