When we traverse in an HTML page by pressing the tab key , a dotted rectangle appears , by which we can identify the position/element in the page. My question is c开发者_JAVA百科an i make it a block i.e the selected elements(links , tabs) color and background will change at the time of traverse ?
You can override the browser's default style as described in this MDC article.
Basic example:
:focus {
background-color: #aaa;
outline: 1px solid red;
}
Demo: http://jsbin.com/otoco5
The :focus
selector works in every browser you could expect, except IE 6 and 7.1,2
You can create a CSS rule using the :focus
pseudo-class:
The :focus pseudo-class applies while an element has the focus (accepts keyboard events or other forms of text input).
精彩评论