interactive-examples icon indicating copy to clipboard operation
interactive-examples copied to clipboard

Inaccessible color contrast ratio in menu element example

Open yashrajbharti opened this issue 5 months ago • 2 comments

What information was incorrect, unhelpful, or incomplete?

The current color scheme of the menu element example does not meet accessible contrast standards, making it difficult to read.

Safari

(EDIT: as mentioned by @estelle, color: buttontext; causes the color of button almost the same as its background resulting in a poor color contrast ratio of 1.2)

Screenshot 2024-09-16 at 11 11 48 AM

Chrome

Screenshot 2024-09-16 at 11 12 12 AM

Firefox

Screenshot 2024-09-16 at 11 12 44 AM

Contrast ratio

Screenshot 2024-09-16 at 11 13 59 AM

What did you expect to see?

I expected the example to use colors that meet the Web Content Accessibility Guidelines (WCAG) 2.1, specifically the contrast ratio of at least 4.5:1 for normal text.

This can be fixed using background-color: black and we can remove the black border (if we want). This fixes both the color between button text and it's background and anchor (link) text and the background.

Screenshot 2024-09-16 at 11 17 01 AM Screenshot 2024-09-16 at 11 17 37 AM

Do you have any supporting links, references, or citations?

You can verify the contrast issue using accessibility testing tools like Contrast Checker or by using browser developer tools to inspect the element's styles.

The menu element example can be found here.

Do you have anything more you want to share?

The issue is reproducible on macOS Monterey using Safari 17.5, Chrome 128.0.6613.138, and Firefox 130.0. It is not browser-specific, as the contrast issue appears consistently across all of them.

yashrajbharti avatar Sep 16 '24 06:09 yashrajbharti