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

Slightly increase contrast for footer text to meet WCAG guidelines #4823

Closed
4 tasks done
lee0c opened this issue Jan 3, 2023 · 14 comments
Closed
4 tasks done

Slightly increase contrast for footer text to meet WCAG guidelines #4823

lee0c opened this issue Jan 3, 2023 · 14 comments
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open

Comments

@lee0c
Copy link

lee0c commented Jan 3, 2023

Contribution guidelines

I want to suggest an idea and checked that ...

  • ... to my best knowledge, my idea wouldn't break something for other users
  • ... the documentation does not mention anything about my idea
  • ... there are no open or closed issues that are related to my idea

Description

The footer text "Made with" (full section reads "Made with Material for MkDocs") which is colored by --md-footer-fg-color--lighter does not meet WCAG contrast guidelines in at least some palettes of this theme. I am using the black palette, but also notice this on the documentation for Material for MkDocs.

I found that changing the value from #ffffff4d to #ffffff73 in browser met contrast guidelines while still allowing for visual difference between the plain text and the link next to it, but I am not a front end dev and am not sure how that translates into the hsla setup used in your stylesheet. Perhaps transparency of 0.4 instead of 0.3?

Use Cases

This would be a small accessibility fix that would benefit any low vision users. It also helps anyone using relevant palettes to meet WCAG guidelines by default, without having to edit colors further.

Screenshots / Mockups

Current coloration in black palette:

image

Here is my version with computed value #ffffff4d replaced with #ffffff73 which meets contrast guidelines

image

@squidfunk
Copy link
Owner

squidfunk commented Jan 4, 2023

Thanks for suggesting and digging into possible solutions. For the footer colors, we already deviate from the standard color definitions as defined via the --md-default-fg-color-* variables, so I guess changing that to 0.4 shouldn't be a problem.

Fixed in 38e2914.

@squidfunk squidfunk added change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open labels Jan 4, 2023
@squidfunk
Copy link
Owner

Released as part of 9.0.2.

@lee0c
Copy link
Author

lee0c commented Jan 4, 2023

Thanks for addressing this so quickly!

@lee0c
Copy link
Author

lee0c commented Jan 9, 2023

@squidfunk Did you do any accessibility testing with the color change? The value I suggested above was a guess due to not being familiar with how you're setting colors - and from preliminary testing with 9.0.2, it looks like I didn't guess high enough. The contrast is better, but still doesn't meet guidelines.

@squidfunk
Copy link
Owner

squidfunk commented Jan 9, 2023

No, I didn't, I trusted your inputs, but I just re-read your original post and now see that you weren't sure.

Reopening, looking into it again.

@squidfunk squidfunk reopened this Jan 9, 2023
@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Jan 9, 2023
@lee0c
Copy link
Author

lee0c commented Jan 9, 2023

Unfortunately I'm not a web dev and am still very much learning this topic. Apologies for not putting more focus on the fact that the value was a guess, I could have bolded or similar and did not.

Thank you for reopening and being willing to take a second look.

@facelessuser
Copy link
Contributor

If you absolutely must have 4.5 for color contrast, you are going to target an alpha around 0.45. Rounding off the contrast gives you 4.5.

>>> bg = Color('#16171d')
>>> fg = Color('hsla(0, 0%, 100%, 0.45)').convert('srgb').compose(bg)
>>> fg.to_string(hex=True)
#7f7f83
>>> bg.to_string(hex=True)
#16171d
>>> fg.contrast(bg)
4.49813259779425

You can play with the results here:

https://facelessuser.github.io/coloraide/playground/?code=bg%20%3D%20Color%28%27%2316171d%27%29%0Afg%20%3D%20Color%28%27hsla%280%2C%200%25%2C%20100%25%2C%200%2e45%29%27%29%2econvert%28%27srgb%27%29%2ecompose%28bg%29%0Afg%2eto_string%28hex%3DTrue%29%0Abg%2eto_string%28hex%3DTrue%29%0Afg%2econtrast%28bg%29

@facelessuser
Copy link
Contributor

Also, keep in mind that the WCAG 2.1 contrast is flawed to some extent. That is why work for WCAG 3 is targeting a different way to calculate contrast. I think they are considering this for 3: https://github.com/Myndex/apca-w3. No decisions are final though. Just an FYI.

@facelessuser
Copy link
Contributor

Also, the above is just calculating color contrast, it does not take into consideration text size and such.

@squidfunk
Copy link
Owner

squidfunk commented Jan 10, 2023

Turtles all the way down 😁 Thanks for the pointers @facelessuser, I'll take a look! And no worries @lee0c, I could have read your issue better, so it's essentially my fault.

@squidfunk
Copy link
Owner

I've checked, and using 0.45 results in #ffffff73. Fixed in 024616f.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jan 10, 2023
@facelessuser
Copy link
Contributor

facelessuser commented Jan 10, 2023

Yeah, I forgot to print out the non-alpha blended value. You are correct, that does in fact equal #ffffff73

>>> Color('hsla(0, 0%, 100%, 0.45)').convert('srgb').to_string(hex=True)
#ffffff73

Anyways, that should be close enough 🙂.

@lee0c
Copy link
Author

lee0c commented Jan 10, 2023

Thank you to both of you, especially for the extra info @facelessuser ! You're totally right that the contrast isn't a perfect fix and I am glad to hear that WCAG 3 is looking more at this, but any improvement helps.

@squidfunk
Copy link
Owner

The latest changes were released as part of 9.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants