DEV Community

Discussion on: CSS can do that?

Collapse
 
ananyaneogi profile image
Ananya Neogi

From accessibility point of view I meant that when we add such content like tooltip on hover, what we can do is add the content in aria-label which will be read by the screen reader and then make use of the samearia-label through are CSS with attr() for the normal flow. In that way we can have consistent content throughout.
Probably should've explained better πŸ™‚

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Hi Anya, thanks for the post, do you mean like this?
Case 1

<p>hello a11y text, important info</p>

Case 2

<p aria-label="hello a11y text"><!--hello a11y text-->important info</p>
p[aria-label]::before {
    content: attr(aria-label);
}

Case 1 reads "paragraph, hello a11y text, important info"

Case 2 reads "paragraph, hello a11y text" only but displays the same as case 1.

If it where me, I would stick to a JavaScript solution with real markup, role and avoid aria-label at all costs, good UX and good content do not need aria-label.

Thread Thread
 
craftyminer1971 profile image
CraftyMiner1971 • Edited

aren't the 'aria-label' tags outdated now?

Thread Thread
 
adam_cyclones profile image
Adam Crockett πŸŒ€ • Edited

No? aria-label attributes still very much a day to day support attribute. They are just not great to use unless you have to, your markup should describe your SR journey without needless overides. Do you have any specification to suggest they are out of date?