Switching to WAI-ARIA
However, having researched ARIA a little for another book, (Responsive Web Design with HTML5 and CSS3 in case you are interested) it struck me that if this information has to go in the DOM purely for styling hooks, it may as well lift a little more weight while it's there.
These same styling hooks can actually be placed in the DOM as WAI-ARIA (https://www.w3.org/TR/wai-aria/) states. The States and Properties section of WAI-ARIA describes the W3C's standardised manner in which to communicate states and properties to assistive technology within an application. In the opening section of the abstract description for WAI-ARIA, it contains this:
These semantics are designed to allow an author to properly convey user interface behaviors ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access