Does hover, active, focus states inherit values?
Yes thats correct, pseudo states inherit values.
For consistency purposes, it is best to only declare the styles which you are changing in your psuedo state rules.
With the following code, the text will always be font-size:1.9em
, with padding-top:10px
regardless of :hover
state:
a
{
color:red;
font-size:1.9em;
padding-top:10px;
}
a:hover
{
color:green;
}
-- SEE EXAMPLE --
No, because an a
element in one of the states is still an a
element, and an element cannot inherit from itself. But any setting that has a
as the selector applies when the element is in one of the states, too.
Thus, when you want some properties to apply to a
elements in all states, then it suffices to set them using the a
selector.
Technically, the two sets of rules in your question are not equivalent, due to differences in selectors, which affect specificity. Situations where this would matter are rare and would involve rather special rules in other stylesheets being applied.