A guide to designing accessible focus indicators
sarasoueidan.com
sarasoueidan.com
I don't have any special accessibility requirements but I do miss the more distinctive cues. And other ergonomic touches like the little underlines that told you keyboard accelerators (I always turn them on where available).
I hope the author doesn't mind, I've just updated my lesson[1] on how to make the <canvas> element more accessible with a link to the article.
[1] - https://scrawl-v8.rikweb.org.uk/learn/eleventh-lesson/
As an example, consider a page that primarily contains a list of items. I set each item up to be a focus target so tabbing through the targets will select each list element in turn.
If I add keyboard shortcuts to navigate the list (e.g. up/down cursor to select previous/next element), should my JavaScript drive focus to the selected element, or should I use an independent mechanism (adding a class, say) to mark the active element? Driving focus feels like the more ‘native’ approach, but I don’t know if there are downsides to potentially taking focus away from other elements on the page (for example).
https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tab...
Naturally creating wrapper elements to pass WCAG 2.1 is a pain, that should be solved in CSS itself.
Maybe I'm not understanding what you mean but `outline-offset` is a property to set the distance between the element border and the outline (and you can use an negative value to make an inset outline, handy for situations like buttons without enough margin for an outline to appear without being cut off).
You can also achieve a similar visual effect by having a box-shadow with two values, the larger one being your visible outline color and the smaller one matching the background color around the element.
https://developer.mozilla.org/en-US/docs/Web/CSS/outline-off...
outlines are preserved and used in Forced Color Modes such as Windows High Contrast Mode, where background colors, border colors, and box shadows are usually overridden by user and system styles
Is this actually a thing? If so, how do I test for this (both in CSS and in practice)? I thought only MSIE had this, and MSIE is dead.Here's a Microsoft article about designing for users who have enabled high-contrast mode (technically websites don't need to do anything at all, as the default browser behaviour gives a pretty decent result):
https://blogs.windows.com/msedgedev/2020/09/17/styling-for-w...
Unfortunately, if you want to test high-contrast mode, you'll need a Windows machine (or VM), as Edge doesn't yet have an emulation mode for it (AFAICT), and BrowserStack doesn't let you change OS settings, only browser settings.
Also with Firefox, on any platform, you can go into the settings, Colors, and set "Override the colors specified by the page with your selections above" to Always. It won't change the colors to the ones actual WHCM users use but that doesn't matter, you can't know what colors they've set and they could be anything.
Edit: If you leave the Firefox setting on "Only with High Contrast themes," the colors will also be overridden on a Mac with "Increase contrast" set. Technically, this is inaccurate, it's acting as if `forced-colors: active` is true on the system when the "Increase contrast" setting really maps to `prefers-contrast: more`. But macOS doesn't yet have an option to convey `forced-colors: active` so Firefox's choice is probably for the best for now.