Reputation: 31
I have a button and I want it to change to green when I access it by tab key. I have written the code for hover by mouse but I want that when a user a goes to the button using tab key then it should change the color.
Upvotes: 1
Views: 4343
Reputation: 71240
Simply use the :focus
pseudo selector
button:focus{
color:green;
}
The :focus CSS pseudo-class is applied when a element has received focus, either from the user selecting it with the use of a keyboard or by activating with the mouse (e.g. a form input).
You may also wish to give the button
a tabindex
attribute to control its tab order.
Upvotes: 6