A few examples of focus styles, mainly for outlines, to inform discussions.
A simple button, no styles, varies considerably by browser:
A simple button, flattened most styles (border = 1px #333 solid
) but didn't touch focus-outline or focus-inner:
No visible border, adding a dark outline on focus.
Pass - high contrast with button background and page background.
Dark border, adding a dark outline on focus, which basically doubles the thickness:
Pass? - Changes the shape of the component, adding a 1px extra to the border.
Dark border, light (#ccc
) outline on focus:
Fail? - Not sufficient contrast with page background to change the shape of the component.
Dark border, dark outline fully outside the button using outline-offset: 2px
:
Pass - Changes shape and the outline contrasts against all adjacent colors.
Dark border, dark outline fully inside the button using outline-offset: -3px
:
Pass - Outline contrasts with the adjacent colours.
Dark border, dark outline fully inside the button using outline-offset: -3px
:
Pass? - Tricky, but conceptually very similar to example 4, increasing the thickness of the border changes the component...
No border, well padded, dark outline fully inside the button using outline-offset: -5px
:
Pass - Outline contrasts with the adjacent colours.
Foreground and background colour inversion:
Pass - no change of shape, but contrasting change of foreground and background.
Subtle background colour change:
Fail - no change of shape, contrast change does not meet 3:1.
The outline is adding inside the component, effectively changing it's shape:
Pass - change of shape.
The outline is adding inside the component, but without contrast so NOT effectively changing it's shape:
Fail - no change of shape.
Three examples showing a 1px border, 1px outset by 1px, and 1px outset by 2px.