highlightjs / highlightjs/highlight.js
Theme accessibility
- Dominant language
- JavaScript
- Stars
- 25k
- Forks
- 3.8k
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 3
Description
Web accessibility is very important. For a syntax highlighting library this is particularly relevant when it's used for a website that is meant to be used by many users, some of whom may not have perfect vision and struggle to read code highlighted with themes that have a low contrast. The WCAG web accessibility standard [defines the following AA success criteria](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html):
>The visual presentation of text and images of text has a contrast ratio of at least 4.5:1
Currently highlight.js already comes with several themes that meet this criteria. However most themes that come with highlight.js do not meet WCAG AA. I don't think that this is a problem per se, since highlight.js might be used just for e.g. just a personal application where the user chooses can choose their own color theme as they wish.
I do however think that highlight.js should address two things:
* If highlight.js comes with themes that do not meet WCAG AA, the [Demo](https://highlightjs.org/static/demo/) should raise awareness about which themes have a high contrast and which themes don't. This could be as simple as dividing the themes list in `Themes with high contrast`, `Themes with lower contrast` and linking some informative web page that explains when/why this matters.
* I find it problematic that the `Default` theme does not meet WCAG AA. I think either it's colors should be changed to meet WCAG AA or it should be renamed to something else (maybe Legacy Default). This is important because accessibility by default is important. (And also because the README currently suggests using `default.css`).
To get this started I opened the pull request #3390 which calculates the minimum WCAG contrasts for each theme and asserts that they are the same as defined in `test/contrast/min_contrasts.json`. (Contrasts can still be decreased but not accidentally).
Contributor guide
Assessment
This issue has not been assessed yet.