Skip to content

A11y: adjust colour contrast for dark theme #5599

@hugovk

Description

@hugovk

Context

No response

Bug description

With the dark theme, pages such as:

don't have enough contrast for the links, making them hard to read and affecting accessibility.

The ratio doesn't meet the WCAG guidelines.

Related links

Reproduction

example.zip

Steps to reproduce

  1. Open site in dark mode
  2. Inspect page in Chrome, select Lighthouse tab
  3. Select Accessibility category (can uncheck others to speed it up)
  4. Click "Analyze page load"
  5. Check results

Expected results:

Score: 100 and no contrast issues

Actual results:

Several contrast issues found:

Details image image

In my view, the top priority would be to fix the colour used for links (var(--md-typeset-a-color)) which especially problematic for pages like https://blog.pypi.org/

Suggestion:

Inspect the problematic text using Chrome:

Details image

Click the colour square in the styles pane and expand the bit next to Contrast ratio:

Details image

Click the box next to AA 4.5 to get a suggested colour:

Details image

This gives #7299e1 which is a good replacement for the problematic #6c91d5.

Note: make sure not to change colours for light mode at the same time, or it may make the contrast worse for light mode.

Browser

Chrome

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestIssue requests a new feature or improvementresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions