News for hackers. Stuff that matters.
Re:Just Use a Button by randyrand on Friday October 31, 2025 @02:34PM (#45775197)
> This element does not announce itself as an interactive element to screen reader users

Are you sure? Screen readers should be able to detect a div with a onclick as interactable, no? And if they can’t, that seems like an exceedingly simple fix. I’d be shocked if they can’t already detect onclick.

Re:Just Use a Button by rictic on Friday October 31, 2025 @02:42PM (#45775278)
A click handler can be doing a lot of things that aren't much like a button, like letting you close a modal if you click outside of it, capturing mouse events for a game, or passively recording events for analytics. All that a click handler tells you is that there's some code that sometimes cares about some clicks somewhere inside that element.
Re:Just Use a Button by randyrand on Friday October 31, 2025 @03:57PM (#45776048)
All of those seem like examples of things you’d want your screen reader to tell you about.
Re:Just Use a Button by zahlman on Friday October 31, 2025 @07:11PM (#45777730)
Sure.

What is the screen reader's plan for determining the purpose of the attached JavaScript?

Re:Just Use a Button by randyrand on Thursday November 06, 2025 @04:46PM (#45840866)
Same as a button. Read the text in the element. If no text, skip it or say "clickable".

I'm not arguing a div is better. I'm just saying screen readers could announce a div with an onclick if they wanted to.

Re:Just Use a Button by knute on Friday October 31, 2025 @03:02PM (#45775493)
Also a click handler on a div isn't going to do much for someone who isn't using a mouse, which would include a lot of screen reader users.
Re:Just Use a Button by 1-more on Friday October 31, 2025 @03:21PM (#45775700)
I can confirm. I got decent with VoiceOver as the "guy on the team who gives a shit about this" (unofficial title) and yeah, it stinks. Also, you don't necessarily move through the page linearly with a screen reader; the rotor lets you jump between links, or jump to forms, or jump to navs. The more semantic your markup, the better it will be populated.
Re:Just Use a Button by cferdinandi on Friday October 31, 2025 @03:48PM (#45775977)
It's worth noting that VoiceOver is well-known for being a lot more lax than most other screen readers. Other options tend to be a lot more strict around standards and what they'll announce.