CSS
CSS.
The objective of this technique is to create a highly visible focus indicator that has sufficient contrast against the internal background color of a component.
The examples demonstrate a simple implementation where a focus styles is applied to blue background. As the indicator is contained inside the component, you can be sure it maintains contrast whatever background the component is placed on
<button type="button">Example button</button>
CSS to provide the indicator. It narrows the scope to buttons within the main element.
button {
background-color: #236AB8; /* medium-dark blue */
color: white;
padding: 10px;
}
main button:focus {
outline: 3px #fff5be solid; /* light yellow */
outline-offset: -4px;
}
For each focusable user interface component:
The required change of contrast for Focus Appearance (Minimum) is 3:1, this technique goes slightly beyond the minumum requirement.