Alt attribute for ASCII art in HTML?

Issue

This is a very (very) specific question, but would it be appropriate to use the alt attribute for a pre tag when using that to show ASCII art? It’s essentially like an image (which wouldn’t be intelligible using a screen reader), so using alt makes sense.

<pre alt="A cute little blob creature">༼ つ ◕_◕ ༽つ</pre>

Would is be read by a screen reader? Would this be appropriate or good form?

(I could imagine other situations where this might arise, like using a typographical object to denote a particular action, such as a "home" link.)

Solution

The aria-label attribute exists for this purpose.

<pre aria-label="A cute little blob creature">༼ つ ◕_◕ ༽つ</pre>

For more information, check out this MDN article on it.

Answered By – Niet the Dark Absol

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.