Please see the associated blog article for background.
1 - Default, no CSS applied.
Link 1
2 - Outline removed.
Link 2
3 - Outline removed, then put back as author style.
Link 3
4 - Outline removed on :focus
and :active
, then put back as author styled :focus
.
Link 4
5 - Outline removed, then webkit focus added, plus an author fallback for non-webkit browsers.
Link 5
6 - Outline removed, colours switched on :focus
.
Link 6
7 - Outline removed, with a:focus:hover
.
Link 7
The zen approach is to not remove the outline style, and to either leave it alone or change something like the foreground/background colour.
If you need to remove outlines from particular links, I would use this:
a.specific-class:focus:hover { outline: none; }
The table below shows the results from the above conditions across various browsers. I've added a background colour to indicate whether it is 'good' or not. I.e. an outline style must show when using the keyboard, and should not show when using a mouse. I've left 'author outline' neutral for keyboard as that's ok, but does depend on what the author has picked as the outline, ideally it would be the user's preference.
NB: The table is wide, you might need to horizontally scroll.
Condition | Chrome 53, MacOS | Firefox 47, MacOS | Safari 10, MacOS | Edge, Windows 10 | IE 11, Windows 10 | iOS 10 | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Keyboard | Mouse | Keyboard | Mouse | Keyboard | Mouse | Keyboard | Mouse | Keyboard | Mouse | VoiceOver | ||
1 | Default outline | No outline | Default outline | No outline (Unless keyboard used first) |
Default outline | No outline | Default outline | No outline | Default outline | No outline | No outline | |
2 | No outline | No outline | No outline | No outline | No outline | No outline | No outline | No outline | No outline | No outline | No outline | |
3 | Author outline | Author outline | Author outline | Author outline | Author outline | No outline | Author outline | Author outline (onMouseDown) |
Author outline | Author outline (onMouseDown) |
Grey outline | |
4 | Author outline | Author outline shown (onMouseUp) |
Author outline | No outline | Author outline | No outline | Author outline | Author outline (onMouseUp/Drag) |
Author outline | Author outline shown (onMouseUp) |
Grey outline | |
5 | Default outline | No outline | Author outline | No outline | Default outline | No outline | Author outline | Author outline (onMouseUp/Drag) |
Author outline | Author outline shown (onMouseUp) |
No outline | |
6 | Author outline | Author outline | Author outline | Author outline | Author outline | No outline | Author outline | Author outline (onMouseDown) |
Author outline | Author outline (onMouseDown) |
Grey outline | |
7 | Default outline | No outline | Default outline | No outline | Default outline | No outline | Default outline | No outline | Default outline | No outline | Grey outline |
The outline is often odd when you have block elements floated to one side, like the following example: