So I have an HTML button, with 2 divs inside it - each of which displays certain text. Sample code below. I need to insert some text between the 2 divs such that it is only to be read by screen readers and isn't needed visually speaking. This is a large shared component so I can't really modify the control itself, hoping to just tweak the accessibility part:-
I tried using aria-label on div2, and arialabelledBy keeping the label text hidden on the screen (display: none).
<button>
<div id="div1" >Main text here</div>
<div id="div2" >sub text here</div>
</button>
In the above example, I need the screen reader to read something like:- "Main text here, in between, sub text here". How do i represent "in between" above. I tried aria-label \ labelledBy but those get ignored by Narrator.
aria-labelledby
on the button itself and point it to “div1 betweentext div2”, thus concatenating your way to the required result. – Tobias Christian Jensen