Improve Chart Accessibility with the figure Element
HTML5 introduced thefigureelement and the relatedfigcaption. Used together, these items wrap a visual representation (like an image, diagram, or chart) along with its caption. Wrapping these elements together gives a two-fold accessibility boost by semantically grouping related content and providing a text alternative explaining thefigure.
For data visualizations like charts, the caption can be used to briefly note the trends or conclusions for users with visual impairments. Another challenge covers how to move a table version of the chart's data off-screen (using CSS) for screen reader users.
Here's an example - note that thefigcaptiongoes inside thefiguretags and can be combined with other elements:
<figure><imgsrc="roundhouseDestruction.jpeg"alt="Photo of Camper Cat executing a roundhouse kick"><br><figcaption> Master Camper Cat demonstrates proper form of a roundhouse kick. </figcaption></figure>
Camper Cat is hard at work creating a stacked bar chart showing the amount of time per week to spend training in stealth, combat, and weapons. Help him structure his page better by changing thedivtag he used to afiguretag, and theptag that surrounds the caption to afigcaptiontag.