a:focus anchor pseudo class

You probably know about the a:hover pseudo class in CSS which is used for changing a anchor tag style when a user hovers over a link.

Today, I discovered the a:focus pseudo class which does a similar job, but for when a user highlights a link using keyboard navigation (i.e., tabbing to the link). In most cases, I use the basic effect of underlining text when a user hovers over the link. I also now do that when they focus on the link using the following code:

a:hover, a:focus, a:active {
text-decoration: underline;
}

Note, a:active is for when the user clicks on the link. Also, a:active has to be after a:hover in order for it to work.

June 13, 2010 | In General | 1 Comment

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. Testing comments

    Comment by praj — June 14, 2010 #

Leave a comment