26.ÌýElement not highlighted on focus

Highlight on focus incorrect example

Description:ÌýWith keyboard navigation it is important that the focused component can be visually identified. If the focused component is not somehow highlighted, the user cannot be sure which component has focus.

Context:ÌýWhile browsers should handle this by default, certain styling methods will break this functionality. For example do not disable the ‘outline:none’ property that surrounds an element on focus unless you are offering an alternative. Be sure to use both the ‘:focus’ and ‘:hover’ selectors to cover both mouse and keyboard focus.

a:hover, a:active, a:focus {
    text-decoration: none;
    color: green;
}

How to fix it:ÌýMake sure that user interface elements, that can receive keyboard focus, are highlighted on focus.

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

Techniques:Ìý,Ìý,Ìý