You should add focus triggers to show the tooltip as well. It's important to remember that not everyone uses a mouse or similar pointing device. Adding focus triggers makes it more accessible. Test with screen readers though, some might need additional aria-* attributes to read out the tooltip in the most convenient way for the user.
Thank you for mentioning about a11y, That is an important factor in making web accessibility easier.
Having said that, aria-* can be added directly to the HTML element instead of the tooltip, because here, we are creating a tooltip using CSS alone, without any js overhead.
Not all keyboard users are screen reader users, so aria won't help them. For example, somebody with Parkinson's or a broken wrist might be using a keyboard as they struggle with a mouse or similar pointing device. For these users, using focus styles can mean the tooltip is available to them.
It's up to the developer to decide who is the targeted audience, It is very simple to achieve this as well, along with :hover he needs to define :focus as well.
I think in terms of accessibility, it's not about who we think our target audience is, but about making sure we're not discriminating against people because we thought they aren't our audience. Like you said, simply using :focus to trigger the display of the tooltip should resolve its visibility for those. But there might be some other edge cases where testing with a screen reader should be done too.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You should add
focus
triggers to show the tooltip as well. It's important to remember that not everyone uses a mouse or similar pointing device. Adding focus triggers makes it more accessible. Test with screen readers though, some might need additionalaria-*
attributes to read out the tooltip in the most convenient way for the user.Thank you for mentioning about
a11y
, That is an important factor in making web accessibility easier.Having said that,
aria-*
can be added directly to the HTML element instead of the tooltip, because here, we are creating a tooltip using CSS alone, without any js overhead.Not all keyboard users are screen reader users, so aria won't help them. For example, somebody with Parkinson's or a broken wrist might be using a keyboard as they struggle with a mouse or similar pointing device. For these users, using focus styles can mean the tooltip is available to them.
I completely agree with you.
It's up to the developer to decide who is the targeted audience, It is very simple to achieve this as well, along with
:hover
he needs to define:focus
as well.I think in terms of accessibility, it's not about who we think our target audience is, but about making sure we're not discriminating against people because we thought they aren't our audience. Like you said, simply using
:focus
to trigger the display of the tooltip should resolve its visibility for those. But there might be some other edge cases where testing with a screen reader should be done too.