Bring your karma
Join the waitlist today
HUMBLECAT.ORG

Blind and Visually Impaired Community

Full History - 2021 - 08 - 12 - ID#p3457o
10
[deleted by user] (self.Blind)
submitted by [deleted]
[removed]
kotyy 8 points 1y ago
In terms of actual emoji, I *believe* screen readers will read off an actual description of the emoji, based upon the unicode description. i.e., 💗would be described as 'growing heart.'

In terms of a string of characters as an emoticon, aria-label would be my first thought:

<span aria-label="smiling person with flower in their hair">(✿◠‿◠)</span>

But as ellvix said, aria-labels on spans may not be reliable, so consider adding the text description into the page, but visually hiding it. BUT, we can't use the CSS visibility or display properties, as they'll also prevent screen readers from picking up on the content, so we'll have to rely upon some old-hat techniques of positioning the content off the page. *Do not do this* if the element is interactable (button, link) *without* also positioning it appropriately when focused.

<span aria-hidden="true">(✿◠‿◠)</span>
<span class="visually-hidden">emoticon: "smiling person with flower in their hair"</span>

.visually-hidden {
position: absolute;
left: -999rem;
height: 1px;
width: 1px;
overflow: hidden;
}

If someone else wants to chime in, I'm curious how screen readers would handle elements with visibility and aria-hidden, such as:

<span aria-hidden="false" style="visibility: hidden;">emoticon: "smiling person with flower in their hair"</span>

If this approach is valid, I'd prefer it over the positioning off of the page.

(I am not blind, but I am a web developer who cares about accessibility.)
TheDonF 4 points 1y ago
The aria-label, aria-labelledby, and aria-describedby attributes won't work with <div> and <span> elements unless they have a suitable role attribute. See the $1 for more on this.

I guess you could mark up the emoticon with a role="img" attribute and then use an aria-label attribute to give it an accessible name. That's a lot less hassle than dealing with extra visually-hidden text content. So:

<p>Today I saw a <span aria-label="smiling person with flower in their hair" role="img">(✿◠‿◠)</span></p>
MostlyBlindGamer 3 points 1y ago
Use an extra invisible span that can be read by a screen reader. Look up the .sr-only class in Bootstrap, for example.
[deleted] [OP] 3 points 1y ago
[deleted]
zersiax 2 points 1y ago
you could add an aria-label, that overrides the content of the span with the new value for screenreaders only. Only way I can think of to do this for a span.
ellvix 5 points 1y ago
aria-label isn't very reliable with span though, maybe visually hidden text and then aria-hidden the emoticon?
zersiax 1 points 1y ago
That would work as well, yes :)
This nonprofit website is run by volunteers.
Please contribute if you can. Thank you!
Our mission is to provide everyone with access to large-
scale community websites for the good of humanity.
Without ads, without tracking, without greed.
©2023 HumbleCat Inc   •   HumbleCat is a 501(c)3 nonprofit based in Michigan, USA.