Tutorials Point


  CSS Home

  CSS Reference
  Pseudo Classes & Elements

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

CSS Pseudo-class :focus


previous next AddThis Social Bookmark Button


Advertisements

Description:

The :focus pseudo-class is used to add special effect to an element while the element has focus.

While defining pseudo-classes in a <style>...</style> block, following points should be taken care:

  • a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.

  • a:active MUST come after a:hover in the CSS definition in order to be effective.

  • Pseudo-class names are not case-sensitive.

  • Pseudo-class are different from CSS classes but they can be combined.

Possible Values:

  • color: Any valid color value.

Applies to:

Anchor / Link element.

Example:

Following is the example which demonstrates how to use :focus class to change the color of focused links.

<style type="text/css">
a:focus {color: #0000FF}
</style>

<a href="/html/index.htm">Click this Link</a>

This will produce following link. This will change it color to orange when this link gets focused, then you focus on any other link to see that this color will change when it will lose focus.

Click This Link

To Become more comfortable - Do Online Practice



previous next Printer Friendly

Advertisements


  

Advertisements