I'm trying to add "invisible" supplementary content to HTML elements and I would like to avoid creating new elements in the DOM. I would also like to maintain accessibility as much as I can (i.e. read out by screen readers VoiceOver and JAWS). How would I do this?
Note: In my context, supplementary content mostly consists of help text, but there are some instances where additional information will appear. For sighted users, this content might appear in a non-modal alert box or tooltip, for instance.
I can use the
title
attribute, but there seems to be quite a few problems associated with this. Also I'd like to be able to customize the appearance of the text (whether it be a custom tooltip or widget) andtitle
will produce the browser's default tooltip.I can put the content into the
aria-label
attribute, but this seems to be more appropriate for alternative content rather than supplementary content.The most accessible method seems to be
aria-describedby
, however that would require the content to be put into a separate DOM element with an ID along with ARIA roletooltip
, which isn't really feasible at this point in time.Finally there's the HTML5
data-*
attributes, which are there for content to be used in scripts and such, but there's nothing about the accessibility of that.
An attribute is preferable because I can also access the contents using the CSS attr()
method if I do not use JavaScript. Then again, do screen readers read generated content?