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

1.4.1 Use of color: adding examples to understanding text #3717

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

detlevhfischer
Copy link
Contributor

@detlevhfischer detlevhfischer commented Feb 26, 2024

Adding two examples for using color in focusing elements with the keyboard, one for links that have an additional underline, and one for buttons where the background color changes and focused and unfocused background have a contrast difference equal to or better than 3:1.

Background: The Understanding Text of 1.4.11 Non-Text Contrast has Figure 15 where it says:

The change of background within the component is not in scope of non-text contrast. However, this would not pass Use of color.

There is so far no example how 1.4.1 applies to keyboard focus states so this might be helpful.

Adding two examples for using color in focusing elements, one for links that have an additional underline and one for buttons where the background color changes and focused ansd unfocused background habve a contrast difference equal or better than 3:1.
Copy link
Member

@patrickhlauke patrickhlauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to provide a small image with each of these to illustrate the point (but yes, I know this is always a bit of a pain to do)

@detlevhfischer
Copy link
Contributor Author

@patrickhlauke Agree. I have added illustrations. The text probably needs some further tweaking.

Rendered version

@bruce-usab
Copy link
Contributor

bruce-usab commented Feb 29, 2024

@detlevhfischer could you be on the TF call next Friday (8 March)?

As has been the pattern, probably alastair or Michael will be screen sharing but we would like you (or someone who has reviewed) to walk the group through the PR.

@detlevhfischer
Copy link
Contributor Author

detlevhfischer commented Mar 1, 2024

but i assume what you had in mind here is that the dark blue is not 3:1 against the non-focused blue, right?

I think for a link in blue that has sufficient contrast to a white background AND 3:1 to the surrounding text (assumed to be black here), it would not even be possible to find a color on focus that both has 3:1 or better to the unfocused state AND maintains 3:1 or better to the surrounding text. Showing that this will not work so that some other differentiator (underline, bold or whatever) is needed would be the point for inline links.

@detlevhfischer
Copy link
Contributor Author

@bruce-usab I'll try to be on the Friday call next week.

understanding/20/use-of-color.html Outdated Show resolved Hide resolved
Copy link
Member

@scottaohara scottaohara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggested wording changes / alt text updates for the added graphics

understanding/20/use-of-color.html Outdated Show resolved Hide resolved
<h3>Focus on links</h3>
<p>A block of text has a text link in blue that has a contrast of 3:1 to the surrounding text. When this link receives keyboard focus, it turns into a darker blue. The contrast difference between the link color in the focused and the unfocused state is only 2.0:1. In addition, after receiving focus the contrast difference between the link and the surrounding text is now also well below 3:1. To show the keyboard focus clearly, the link is in addition underlined, so the change of color is not the only indicator of keyboard focus. Without an additional focus indicator the example would fail the Success Criterion 1.4.1 Use of Color.</p>
<figure id="figure-text-links">
<img src="img/textlink.svg" alt="A blue inline text link in a block of black text, before and after receiving keyboard focus" width="500" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<img src="img/textlink.svg" alt="A blue inline text link in a block of black text, before and after receiving keyboard focus" width="500" />
<img src="img/textlink.svg" alt="Two instances of the same paragraph of text containing a hyperlink. The first instance shows the unfocused hyperlink with blue colored text with no underline. The second instance shows the same hyperlink in the focused state, now with darker blue text and an underline" width="500" />

understanding/20/use-of-color.html Outdated Show resolved Hide resolved
understanding/20/use-of-color.html Outdated Show resolved Hide resolved
@fstrr
Copy link
Contributor

fstrr commented Mar 8, 2024

I must be missing something with this, as F73, "Failure of Success Criterion 1.4.1 due to creating links that are not visually evident without color vision", seems to contradict it.

In this PR, we're saying that a link with no default underline can pass Use Of Color if it gets an underline on hover and/or focus. F73 seems to contradict that:

While some links may be visually evident from page design and context, such as navigational links, links within text are often visually understood only from their own display attributes. Removing the underline and leaving only the color difference for such links would be a failure because there would be no other visual indication (besides color) that it is a link.

Example 2 in F73 seems to back that up: an inline link with no underline, but that gets an underline in its hover state, fails.

Am I missing something obvious?

@scottaohara
Copy link
Member

scottaohara commented Mar 8, 2024

@fstrr the scenario here says that the non-underlined link is a color that passes the 3:1 ratio against the non-hyperlink text. so that's why it would be a pass.

maybe it'd be good to call out that even though this is a pass, it is still generally not recommended.

edit:
actually, i think we have a problem with the linked technique, since #f00 compared to #000 (assuming the paragraph text is #000) would have a 5.25:1 ratio. So that technique needs to be clarified and the paragraphs need to have a color that would result in a ratio that is less than 3:1, or Francis is right that there is conflicting interpretations at play here.

edit again:
this text from the understanding doc

If content is conveyed through the use of colors that differ not only in their hue, but that also have a significant difference in lightness, then this counts as an additional visual distinction, as long as the difference in relative luminance between the colors leads to a contrast ratio of 3:1 or greater. For example, a light green and a dark red differ both by color (hue) and by lightness, so they would pass if the contrast ratio is at least 3:1. Similarly, if content is distinguished by inverting an element's foreground and background colors, this would pass (again, assuming that the foreground and background colors have a sufficient contrast

and this passing technique - which links to these passing examples all seems to demonstrate that F73 needs to be fixed.

detlevhfischer and others added 4 commits March 8, 2024 20:24
Co-authored-by: Scott O'Hara <scottaohara@users.noreply.github.com>
Co-authored-by: Scott O'Hara <scottaohara@users.noreply.github.com>
Co-authored-by: Scott O'Hara <scottaohara@users.noreply.github.com>
Co-authored-by: Scott O'Hara <scottaohara@users.noreply.github.com>
fstrr added a commit that referenced this pull request Mar 11, 2024
This PR removes example 2, “Removing the underline from a link in a sentence or paragraph without providing another visual cue besides color”, which contradicts guidance in G183. This issue came up in #3717.
A small patch to clarify one aspect of
#3717
The styles get removed anyway at publication time, but this makes it easier when previewing the in-flight PR
@patrickhlauke
Copy link
Member

Swapped out base.css for editors.css for better previewing

@patrickhlauke
Copy link
Member

Rendered preview https://raw.githack.com/w3c/wcag/1.4.1-examples-added/understanding/20/use-of-color.html

@detlevhfischer
Copy link
Contributor Author

Nice, thanks for all the good edits! In a separate step, it's perhaps a good idea to still add a paragraph undo "Intent of Use of Color" so the example chimes with something explained before, as @u9000-Nine has hinted at.

@mbgower mbgower requested a review from ljoakley May 10, 2024 15:33
@mbgower mbgower assigned ljoakley and fstrr and unassigned ljoakley May 10, 2024
@fstrr
Copy link
Contributor

fstrr commented May 21, 2024

What I think would be useful would be to have the Focus On Links image match the ratios in the preceeding paragraph. I found that having two almost identical examples, one in text and one as an image, next to each other a little confusing.

In last week's backlog meeting, I think we discussed adding a note stating that if the example's underline was under 3:1 contrast, that would be a Non-Text Contrast issue. If I'm remembering that correctly, adding that would also be useful.

in response to @fstrr s comment, in the paragraph preceding the illustration of the inline link, I changed contrast value of default link color to surrounding text color to 3.8:1. I also added the actual value of 2.0:1 between link color and surrounding text after the link receives focus,
@detlevhfischer
Copy link
Contributor Author

detlevhfischer commented May 22, 2024

@fstrr Does my latest change of contrast values in the text preceding the illustration of inline link in default and focused state and the addition of a note on required underline contrast address your concerns?
Here is an updated rendered preview: https://raw.githack.com/w3c/wcag/d02f34b44294194950aaba9f189a27dd3ac2acbf/understanding/20/use-of-color.html

Changed "just under 4:1" in the fig legend to the actual value of 3.8:1 (because it is also used in the text above the illustration).
Added a note that the underline must have at least 3:1 contrast.
@fstrr
Copy link
Contributor

fstrr commented May 28, 2024

@detlevhfischer Thanks for this. A couple of things:

  1. Is the initial contrast actually 3.83:1 and not just 3.8:1?
  2. Would changing the underline note to say this be clearer?:

Because the focus state's text color has a contrast of less than 3:1 with the surrounding non-link text, the underline must have a contrast of at least 3:1 otherwise the underline would fail Success Criterion 1.4.11 Non-Text Contrast

And, as it's a note, should it be marked up as a note?

Thanks :)

the numbers.</p>

<h3>Focus on links</h3>
<p>A block of text has a text link in blue that has a contrast of 3:1 to the surrounding text. When this link receives keyboard focus, it turns into a darker blue. The contrast difference between the link color in the focused and the unfocused state is only 2.0:1. In addition, after receiving focus the contrast difference between the link and the surrounding text is now also well below 3:1. To show the keyboard focus clearly, the link is in addition underlined, so the change of color is not the only indicator of keyboard focus. Without an additional focus indicator the example would fail the Success Criterion 1.4.1 Use of Color.</p>
Copy link
Contributor

@mbgower mbgower Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>A block of text has a text link in blue that has a contrast of 3:1 to the surrounding text. When this link receives keyboard focus, it turns into a darker blue. The contrast difference between the link color in the focused and the unfocused state is only 2.0:1. In addition, after receiving focus the contrast difference between the link and the surrounding text is now also well below 3:1. To show the keyboard focus clearly, the link is in addition underlined, so the change of color is not the only indicator of keyboard focus. Without an additional focus indicator the example would fail the Success Criterion 1.4.1 Use of Color.</p>
<p>A blue text link has a contrast of 3:1 with the surrounding block of black text, and so is not relying on color alone. However, when this link receives keyboard focus, it turns a darker blue. The contrast between the link color in the focused and the unfocused state is only 2:1. In addition, after receiving focus the contrast difference between the link and the surrounding text is now also well below 3:1. To show the keyboard focus clearly, the link is in addition underlined, so the change of color is not the only indicator of keyboard focus. Without this additional focus indicator the example would fail the Success Criterion 1.4.1 Use of Color.</p>

@patrickhlauke
Copy link
Member

Looking at this again on today's call, the "Focus on links" is problematic...

@alastc
Copy link
Contributor

alastc commented Jul 12, 2024

It needs an update:

  1. It should note the example fails focus-appearance.
  2. It would be useful to include the basic example for link text without a underline before this more niche case. That's the common case, and skimming the document it wasn't as clear as this niche case.

@patrickhlauke patrickhlauke self-assigned this Aug 30, 2024
@patrickhlauke
Copy link
Member

patrickhlauke commented Aug 30, 2024

I'm going to work some more on this PR (hope that's ok, @detlevhfischer). My initial thinking is:

  • it could benefit from a note/addition to the understanding prose (before the examples), so mention how "Use of Color" can also apply in situations relating to focus and on/off toggle states
  • make an initial example that just shows the more common "links without underline that rely on color to be distinguishable from regular text"
  • tweak Detlev's example of the focus state for the link to become a follow-up to the previous example - might also see if we can do it so that it doesn't fail focus appearance
  • make another example that talks about a series of two/three buttons, one of which is toggled/pressed, but only uses a subtle difference in background colour to visually show that it's toggled/pressed
  • create images/svgs for the existing two examples (the required fields that use colour and an icon, and the chemical compound image that uses colour and numbers to list the different atoms)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.