+ 7
what does a:active do in CSS?
4 Réponses
+ 3
Abir Sheikh
It is a pseudoclass that can be applied to a focusable element just like other pseudoclasses, hover and focus.
These are usually used to visually differentiate different states of a focusable element by applying different styles.
For example, I want a button element to have different background colours to indicate different states.
CSS
--------------
button{
background: #ddd;
}
button:hover{
background: orange;
}
button:focus{
background: red;
}
button:active{
background: green;
}
---------------
See this page: https://developer.mozilla.org/en-US/docs/Web/CSS/:active
+ 4
This is a pseudoclass like hover but this works when you
Click
0
Hey there!
As mentioned by Muhammadamin , it is a pseudoclass. Using this you can style the active link differently than the others in the same segment.
Eg: In a navigation bar, the tab that is currently opened is often styled differently than the other tabs.
- 1
Selects active links.