Make WordPress Core

Opened 16 months ago

Closed 14 months ago

Last modified 9 months ago

#63449 closed defect (bug) (fixed)

Low color contrast for <code> elements in description text on Settings > General page

Reported by: sainathpoojary Owned by: joedolson
Priority: normal Milestone: 6.9
Component: Administration Version: 6.5
Severity: normal Keywords: has-patch has-test-info commit
Cc: Focuses: accessibility

Description

On the Settings > General admin page, there is a descriptive paragraph about the Site Icon that includes an inline <code> element:

The Site Icon is what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. It should be square and at least <code>512 by 512</code> pixels.

The <code> element is styled with a semi-transparent light gray background rgba(0, 0, 0, 0.07) and inherits its text color #646970 from the parent paragraph.

This combination results in insufficient color contrast between the text and background, failing WCAG 2.1 AA and AAA contrast requirements. The issue is detected by tools like Lighthouse and WebAIM.

This is because there is a fixed background property set for the <code> block but no color property is defined, which results in inheriting the parent text color, potentially leading to unpredictable and inaccessible color contrast depending on the context.

Steps to Reproduce

  1. Go to Settings > General in a fresh WordPress install.
  2. Run a Lighthouse accessibility audit.

Screenshots:

https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyOLkGVv6eKbdmxBDqZFPO905ga2ljtv4iur8Kf

Change History (11)

This ticket was mentioned in PR #8809 on WordPress/wordpress-develop by @sainathpoojary.


16 months ago
#1

  • Keywords has-patch added

This PR fixes a low color contrast issue for <code> and <kbd> elements in the WordPress admin by setting a default text color #44464B to ensure compliance with WCAG 2.1 standards. Previously, these elements had a fixed light background but inherited text color, which in some contexts (e.g., the Site Icon description on the General Settings page) led to insufficient contrast flagged by accessibility tools like Lighthouse and WebAIM.

Trac ticket: #63449

https://github.com/user-attachments/assets/ca6839d6-fd4c-4098-ae7f-d617656554d3

#2 @pmbaldha
16 months ago

  • Keywords has-test-info added

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8809

Environment

  • WordPress: 6.9-alpha-20250515.062152
  • PHP: 8.2.10-dev
  • Server: PHP.wasm
  • Database: WP_SQLite_Translator (Server: 5.5 / Client: 3.40.1)
  • Browser: Chrome 136.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

https://ibb.co/7NgkJ90d

#3 @sabernhardt
16 months ago

#63236 was marked as a duplicate.

#4 @sabernhardt
16 months ago

  • Version trunk

There are two recent pull requests about this.

  • PR 8809 assigns a darker color to any code or kbd element. The #44464B gray is not in the admin color palette. That color would also make code elements lighter on the Permalinks Settings page, where they currently match the #3c434a color for body text.
  • @dilipbheda assigned a darker #3c434a text color to p.description code, which is more restrictive, in PR 8653.

More contrast is usually better, but I think both proposed colors are unnecessarily dark inside the .description paragraphs. The #646970 paragraph text has a ratio of 4.86:1 against the #f0f0f1 gray body background. The next-darkest gray is #50575e, which would give the site icon dimensions a 5.50:1 ratio (slightly higher than the surrounding paragraph text, but not as drastic as 7.53:1 with #3c434a or 7.09:1 with #44464B).

As much as I do not want the body background changed to white (see ticket #62831), that technically would solve the issue without requiring additional CSS on this ticket. It would increase the contrast for code elements in .description paragraphs from an insufficient 4.15:1 to a passing ratio of 4.72:1.

Increasing the paragraphs' color contrast is another possibility:

p.description,
.form-wrap p {
	margin: 2px 0 5px;
	color: #50575e;
}
Last edited 16 months ago by sabernhardt (previous) (diff)

#5 @sabernhardt
16 months ago

  • Version6.5

[57713] switched a strong tag to code for the site icon dimensions, though any code element in a .description paragraph could have had insufficient contrast earlier than that (and [50025] decreased it from 4.35 to 4.15).

Last edited 16 months ago by sabernhardt (previous) (diff)

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


14 months ago

#7 @joedolson
14 months ago

  • Milestone Awaiting Review6.9
  • Owner set to joedolson
  • Status newaccepted

I'm inclined to broaden the version for this, since while the specific instance of this only exists since 6.5, the situation that causes it dates back significantly further; any usage of code in an admin page would trigger it, and there are likely other cases.

Given that there is no certainty that the change to a white background will happen, I think this is something that should just be fixed. If the background color is changed to white, there will be a host of additional color changes that will need to follow, and this can be re-addressed at that time.

I agree with #50575e as a good color option. It's a subtle change that fixes the problem without any extreme changes.

#8 @sainathpoojary
14 months ago

I have updated the PR to include color #50575e for code elements in .description paragraphs. This improves contrast and passes Lighthouse accessibility checks.

https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyOGtlDYzNEeschquBM6yNU3LCFxWSw4rTfmliR

#9 @joedolson
14 months ago

  • Keywords commit added

#10 @joedolson
14 months ago

  • Resolutionfixed
  • Status acceptedclosed

In 60481:

Administration: Fix color contrast code in .description.

Fix a color contrast failure by changing the color of code elements inside form description fields to #50575e.

Props sainathpoojary, pmbaldha, sabernhardt, joedolson.
Fixes #63449.

@SergeyBiryukov commented on PR #8809:


9 months ago
#11

Thanks for the PR! This was merged in r60481.

Note: See TracTickets for help on using tickets.