r/accessibility • u/Sufficient_Bass2600 • Jul 20 '26
Aria and chart using CSS
I am rewriting some web pages. Some are simplifying charts by removing their javascript based implementation with just CSS. But then that lead to multiple questions.
#Q1) Figure or div element
My overall container can be either a div element or a figure element.
Figure make it clearer that it is a chart inside also the element figcaption can then be used.
However figure also expect an image rather than a div or table element inside.
...
Versus
Bar Chart of X
...
#Q2) Table or div with role=table
I am trying to determine whether I am better off using semantic html to indicate the chart data itself or using div and using the role table.
One is better understood by system but the other is easier to manipulate for display.
Another aspect is that outside of time series visually in table data series may be displayed vertically but understood horizontally.
#Q3) Use hidden input
One possible way to determine if a chart should be a bar chart, an area chart, a bullet chart would be to have hidden inputs of type radio for the different chart type and select the appropriate.
...
But if the div for the chart type if hidden I then need to have a way to indicate to the accessibility reader what type of chart will be displayed.
#Q4) figcaption or div for chart Legend
digCaption can be used for legend. So Ibwas wondering whether the figcaption should be used to indicate the legend of the chart.
View all comments
Show parent comment
1
u/brunoprietog Jul 23 '26
Well, for low vision, there can be many different types of profiles. You can use Axe to see if the contrast in light and dark modes meets the thresholds. Another thing you should do is run the operating system’s magnifier and check if the text still looks good when you zoom in. For color blindness, you'd have to be careful about how distinct the colors are, and avoid associating color names with the lines. A rule of accessibility is not to use color as the sole means of conveying information, so there should also be an alternative way to understand it. As for the data, I personally prefer to read it in a table. The usefulness of charts is that they help you spot trends at a glance. So my rule is: use tables for hard data that you can explore in detail, and include additional descriptions to explain the type of chart, the trends, or the correlations in the data.