Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "a:active" and ".active a.class"

I have in a css file this:

#toolbar a.opener:hover,
#toolbar a.opener:active,
#toolbar a.opener:focus {
    something1;
}
#toolbar .active a.opener {
    something2;
}

Questions:

  1. What is the difference between the "first active" and the "second active"?
  2. When are called the "first active" and the "second active"?
like image 958
Iker Aguayo Avatar asked Dec 24 '22 08:12

Iker Aguayo


2 Answers

The first rule incorporates "pseudo" classes, which target the element when it's in a certain state. The :active pseudo-selector applies to the element when the user is clicking on it.

The latter rule is simply a class selector, which applies to an anchor element which has the class "opener" and is a descendand of an element which has the class "active".

like image 134
HaukurHaf Avatar answered Dec 26 '22 20:12

HaukurHaf


:active specifies the state in which an element is in. An element is :active when it is clicked on or gains focus through other means.

.active refers to a class name. In this case, the CSS rule applies to an element that has the active class within the #toolbar parent element.

like image 37
J. Titus Avatar answered Dec 26 '22 21:12

J. Titus