←back to thread

108 points liquid99 | 3 comments | | HN request time: 0.634s | source
Show context
notpushkin ◴[] No.43360319[source]
Like others have already said, it’s an accessibility nightmare. On the other hand, it’s not like this is going away anytime soon – maybe screenreaders could learn to understand and read some such “fonts” (e.g. bold/italic at least)?
replies(3): >>43360462 #>>43360722 #>>43360966 #
peebeebee ◴[] No.43360722[source]
For HTML, you can probably do the following:

  <span aria-label="my text">𖢑ꚲ 𖢧𖤟𖤗𖢧</span>
replies(2): >>43360772 #>>43361083 #
1. chrismorgan ◴[] No.43361083[source]
<https://www.w3.org/TR/using-aria/#practical-support-aria-lab...>:

> • Don't use aria-label or aria-labelledby on any other non-interactive content such as p, legend, li, or ul, because it is ignored.

> • Don't use aria-label or aria-labelledby on a span or div unless its given a role. When aria-label or aria-labelledby are on interactive roles (such as a link or button) or an img role, they override the contents of the div or span. Other roles besides Landmarks (discussed above) are ignored.

replies(1): >>43377137 #
2. notpushkin ◴[] No.43377137[source]
Good point. Any ideas how to implement it properly?
replies(1): >>43378193 #
3. chrismorgan ◴[] No.43378193[source]
I have often wanted to do exactly this, and was disappointed when I learned aria-label couldn’t be used to replace the value exposed for non-interactive content. I have hunted for other techniques a couple of times, and never been completely satisfied, though things have improved in the last year and a bit.

The basic technique is roughly this:

  <span>
      <span aria-hidden="true">displayed text</span>
      <span inert class="visually-hidden">accessibility text</span>
  </span>

  <style>
      .visually-hidden {
          position: absolute;
          width: 1px;
          height: 1px;
          margin: -1px;
          overflow: hidden;
          clip-path: rect(0 0 0 0);
          -webkit-user-select: none;
          user-select: none;
          pointer-events: none;
      }
  </style>
The `inert` attribute is a recent addition which may exclude the accessibility text from find-in-page (maybe desirable, maybe undesirable, depending on the situation). Firefox and Chromium shipped that refinement of its behaviour in the last year and a half, Safari hasn’t yet (and seems to have reservations about the whole idea <https://bugs.webkit.org/show_bug.cgi?id=269909>).

You can also play with putting the accessibility text in a pseudoelement’s content (e.g. <span data-a11y-text=…><span aria-hidden=true>…</span></span> and [data-a11y-text]::after { content: attr(data-a11y-text); … }), which should these days be exposed in the accessibility tree, but Firefox find-in-page now includes generated content (though you can’t bridge real and generated content), and it wouldn’t surprise me if Chromium eventually followed suit, so I’m not convinced it’s worth the bother, especially if you lose `inert` or have to add an element anyway. But keeping it as an attribute instead of a separate element has some appeal.