Skip to content Skip to sidebar Skip to footer

Relationship Between Active And Focused States

Currently I'm trying to understand how :active and :focus pseudo-classes related with each other. Here is my example: Google

Solution 1:

Solution 2:

There is no difference between those two examples...

The :active state works when you clicked on the element...

...:focus works after you clicked the element...

If you see closely, when you click the <a>, it becomes yellow first and then it will become green...

Add some transition delay in the :focus...you will know the rest

Stack Snippet

a:link {
  color: blue;
}

a:visited {
  color: voilet;
}

a:active {
  color: yellow;
}

a:focus {
  color: green;
  transition: all .3s ease 2s;
}
<ahref="javascript:void(0)"target="_blank">Google</a>

Post a Comment for "Relationship Between Active And Focused States"