Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code blocks: Colour contrast issues #4012

Closed
Tracked by #4167
selfthinker opened this issue Aug 8, 2024 · 5 comments
Closed
Tracked by #4167

Code blocks: Colour contrast issues #4012

selfthinker opened this issue Aug 8, 2024 · 5 comments
Assignees
Labels
accessibility audit july 2024 Issues from July 2024 external accessibility audit against WCAG 2.2 criteria

Comments

@selfthinker
Copy link
Contributor

This issue is from the accessibility audit of the Design System website by DAC in July 2024.

DAC's description

  • Page: Password input and Type scale
  • WCAG reference: 1.4.6 Contrast (Enhanced) (Level AAA)
  • Issue ID: DAC_Colour_Contrast_Text_03 and DAC_Colour_Contrast_Text_04

Red on grey

The colour contrast on the red text against the grey background failed to meet the expected ratio to pass WCAG 2.2 AAA. The expected ratio for colour contrast with text should be at least 7:1, however the colour contrast ratio for text within this element is 4.51:1. This may be problematic for visually impaired users.

Foreground: #D13118
Background: #F3F2F1
Font Size: 16px
Ratio: 4.51:1

Screenshot of red code on a light grey background

Current code:

<li>
<a href="/components/password-input/#wcag-autocomplete-attribute">use
<code>autocomplete</code> to securely create and enter passwords</a>
</li>

Green on grey

The colour contrast on the green text against the grey background failed to meet the expected ratio to pass WCAG 2.2 AAA. The expected ratio for colour contrast with text should be at least 7:1, however the colour contrast ratio for text within this element is 5.84:1. This may be problematic for visually impaired users.

Foreground: #00703C
Background: #F8F8F8
Font Size: 19px
Ratio: 5.84:1

Screenshot of green code on a light grey background

Current code:

<pre><code tabindex="0" class="language-scss"><span class="hljs-
keyword">@include</span> govuk-font(<span class="hljs-variable">$size</span>:
<span class="hljs-number">19</span>);</code></pre>
[…]
<pre><code tabindex="0" class="language-scss"><span class="hljs-
keyword">@include</span> govuk-font(<span class="hljs-variable">$size</span> <span
class="hljs-number">19</span>, <span class="hljs-variable">$weight</span>: bold,
<span class="hljs-variable">$tabular</span>: true);</code></pre>
[…]
<pre><code tabindex="0" class="language-scss"><span class="hljs-
keyword">@include</span> govuk-font-size(<span class="hljs-variable">$size</span>:
<span class="hljs-number">19</span>);</code></pre>
[…]

DAC's proposed solution

For sites to meet AAA, they must comply with WCAG 2.2 checkpoint 1.4.6 for colour contrast.
As far as contrast ratio is concerned, it must at least be:

  1. if text is not bold and its size is less than 18pt/24px/1.5em/150%: 7:1 for AAA level
  2. if text is not bold and its size is at least 18pt/24px/1.5em/150%: 4.5:1 for AAA level
  3. if text is bold and its size is less than 14pt/19px/1.2em/118%: 7:1 for AAA level
  4. if text is bold and its size is at least 14pt/19px/1.2em/118%: 4.5:1 for AAA level

Thoughts on solution

We could take inspirations from other syntax highlighting projects, like ericwbailey/a11y-syntax-highlighting or mpchadwick/pygments-high-contrast-stylesheets.

Related issues

Additional instances

This will appear wherever there are code blocks. But they would only need fixing once in the CSS file for code highlighting for all of them.

Needed roles

Designer

@Izabela-16
Copy link
Contributor

@querkmachine from today (16th Oct) stand up, @hazalarpalikli confirmed that this could work, so we are ready to merge it once you are back.

@owenatgov
Copy link
Contributor

Just wanna re-emphesise @selfthinker's comment before we go ahead and merge: #4064 (comment)

@hazalarpalikli
Copy link

@Izabela-16 @querkmachine @owenatgov Leaving this comment here as well:

Hi both,

I’ve been giving this some thought:

I’m fully on board with not using bold for the text. It might unintentionally make it seem like we’re placing more emphasis on certain parts, and could even come across as if we're "shouting" at the users. I think it’s best to keep the text unbolded for a more balanced and approachable tone.

I have some concerns around using orange and red together. I left this comment in the slack earlier:

I noticed that we’re using both orange and red in the code text, but the two colours appear quite similar, which makes it hard to distinguish between them. Since they’re meant to convey different information, it might be confusing. Also the fact that i couldn’t even differentiate the two when i first reviewed this.

So instead we can try replacing orange with purple (#4c2c92) ?

@hazalarpalikli
Copy link

@Izabela-16 just had a chat with Owen, we are removing this ticket from this cycle as it might need some more thinking.

@owenatgov
Copy link
Contributor

Following #4064 as an attempt to fix this, we've decided we're not going to resolve this issue.

@owenatgov owenatgov closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@selfthinker selfthinker added accessibility concern Bug, feature request or question about the accessibility of a portion of a product (not a WCAG fail) and removed accessibility concern Bug, feature request or question about the accessibility of a portion of a product (not a WCAG fail) labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility audit july 2024 Issues from July 2024 external accessibility audit against WCAG 2.2 criteria
Projects
Status: Done 🏁
Development

Successfully merging a pull request may close this issue.

5 participants