: How to markup non-human-language text in HTML? Considering the needs of screen readers, browser spell-checking, search engines, etc. how should non-human-language text be marked up in HTML? Should
Considering the needs of screen readers, browser spell-checking, search engines, etc. how should non-human-language text be marked up in HTML?
Should it be wrapped in a particular tag?
Is there a standard special lang attribute for the enclosing tag (eg. "")?
Note that we may wish to mark up a form input as accepting some sort of non-human-language text.
Examples of non-human-language text:
a short cryptographic hash
a large block of encrypted data
proprietary formal notation
ASCII art
More posts by @Hamaas447
3 Comments
Sorted by latest first Latest Oldest Best
This depends on the actual content (there is an important difference between, e.g., a hash and ASCII art) and the context (editable vs. presented content). So after choosing the appropriate element (and possibly WAI-ARIA), HTML5 offers the following options:
The language tag zxx (IETF BCP 47/IANA registry) can be used for "no linguistic content":
<span lang="zxx"><!-- … --></span>
The translate attribute (HTML5) can be used to specify that the content should not be translated:
<span translate="no"><!-- … --></span>
The spellcheck attribute (HTML5) can be used to specify that editable content should not be checked for spelling/grammar errors:
<textarea spellcheck="false"><!-- … --></textarea>
There's no specific recommendations for WCAG 2.0 or even in HTML5 (yet). You can probably wrap it with a <code> tag (like Joel Etherton suggested).
ASCII art is different though. WCAG recommends that you provide the user a text description and a way to skip it. See H86.
I like to use the <code> tag for anything code-like, hash-ish (pun), or data blocks. I use the <pre> tag for displaying direct ascii output (such as screen grabs from mainframes or art).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.