-
Notifications
You must be signed in to change notification settings - Fork 75
New Rule: inline link in paragraph is distinguishable be4d0c #1010
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
base: develop
Are you sure you want to change the base?
New Rule: inline link in paragraph is distinguishable be4d0c #1010
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback. Looking good so far! 👌
|
||
- they have [distinguishing borders](#distinguishing-borders) | ||
- they have [distinguishing box-shadows](#distinguishing-box-shadows) | ||
- they have different `background-image`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's meant by "different"? Are two images with the same URI different, whether it be a data URI or a URL? Do they have to contain different byte sequences? Do they have to subjectively differ in what they depict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've added an assumption to the definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I don't know if I caught it all, but I caught a bunch. :-)
This rule applies to any HTML element which: | ||
|
||
- has the [semantic role][] of ['link'][link] or a [semantic role][] that inherits from the ['link'][link] role; and | ||
- is a [descendant][] of a `p` element; and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this limited to p
elements? Wouldn't this apply just as well to td
or li
or even just div
elements? It seems to me like you didn't quite capture the essence of what you need to test. I think we should come up with a definition of inline links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial version used "block of text" which we found to be ambiguous. So we opted to focus this rule on paragraphs (it's even in the name). When we get this done, we can then move to another "blocks of text".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're including li
and td
but leaving out div
because you can have all content of a page being a descendant of the same div
.
- An icon immediately before, after or in the link denoting it as a link | ||
- Text immediately before, after or in the link denoting it as a link | ||
- a [distinguishing style][] compared to the other text not based on color alone | ||
- a different color compared to the rest of the text in the paragraph that has at least a 3:1 [contrast ratio](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) difference with the rest of the text and a [distinguishing style][] both when the target element [gains focus][gain focus] and the target element is [hovered][] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is assuming the rest of the text has a single color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. If the rest of the text has more than one color then color can't be a distinguishing factor. Need to add that assumption to the text of the expectation.
- An icon immediately before, after or in the link denoting it as a link | ||
- Text immediately before, after or in the link denoting it as a link | ||
- a [distinguishing style][] compared to the other text not based on color alone | ||
- a different color compared to the rest of the text in the paragraph that has at least a 3:1 [contrast ratio](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) difference with the rest of the text and a [distinguishing style][] both when the target element [gains focus][gain focus] and the target element is [hovered][] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a definition that describes what the color of text is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the text is all of the same color?
|
||
## Assumptions | ||
|
||
This rule assumes that the link is distinguishable from the rest of the text with color, which means it fails SC 1.4.1 when there is not another way to distinguish it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this assumption. The expectation tests for color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expectation is indeed testing for color, but it needs to be a contrast ratio of at least 3:1 for the expectation to be met.
If we leave this assumption out of it; there could be a scenario where the link is not(!) a different color from the rest of the text and this rule would fail it even though it should not fail the SC. (Because you should only fail this SC if you communicate something with color without communicating it in a different way.
Does that help you understand this assumption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, if the link is the same color as the surrounding text, this rule is not applicable (it's an odd gap in WCAG since in those cases it's deemed that the link is indistinguishable for all sighted users, not just those with color deficiency/vision impairment that requires at least a 3:1 contrast - though paradoxically keyboard/AT users are advantages because THEY can get to the links without any problem)
@@ -0,0 +1,11 @@ | |||
-- | |||
title: Distinguishing Styles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this definition use three other definitions, I think this should be a single definition. I don't think we currently have a use for those three as separate definitions. Even if at some point in the future we need it, we can split it out then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if don't have another use for these defintions, it is much easier to read the definitions if they are split like this. Don't you think that it makes it worth to have them split?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer the split up version, but it's mainly a personal choice.
|
||
- An icon immediately before, after or in the link denoting it as a link | ||
- Text immediately before, after or in the link denoting it as a link | ||
- a [distinguishing style][] compared to the other text not based on color alone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The distinguishing style definition compares two elements, here you are comparing the link element to text nodes. I don't think that works. Do you mean to compare the link element to the parent element of the text node? If so, there are a bunch of problems with the distinguishing style definition that needs to be worked through. For example:
<style>
* { box-shadow: #F00 0 0 5px; color: black; }
a { text-decoration: none; }
</style>
<p>Lorem ipsum <a href="">dolar sit amet</a> consectetur.</p>
This link is still distinguishable, because it's shadow is an inline one, whereas the shadow of the rest of the text is on the block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the expectation (and assumptions) for
- comparing elements instead of element and text nodes
- usage of border and box-shadow as distinguishing factors
Rule updated based on changes requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some editorials.
</html> | ||
``` | ||
|
||
### Inapplicable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the need to remove the underline from examples 3 - 6. By keeping the underline, the test cases focus on the relevant parts of the (in)applicability.
I would suggest adding an inapplicable test case with a link that is not distunguised using colour. I see that this is handled as an assumption and may not need its own test case?
|
||
Each target element has either: | ||
|
||
- content (such as an image or text) inside, or immediately before or after the test target, that identifies it as a link; or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be made a little more unambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do you think it's ambiguous here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content (such as an image or text) inside [...]
"Content" by itself is pretty broad and open to interpretation. Given that the rule explicitly refers to "content [...] that identifies [the link] as a link", on second thought I don't think that's an issue though.
[...] immediately before or after the test target [...].
In visual order or in tree order?
- a `box-shadow` style property with a color value different from `transparent` or the `background-color` of the target element; or | ||
- a `border` style property with a color value different from `transparent` or the `background-color` of the target element; or | ||
- a different color, compared to the color of the other descendant visible text nodes of the same _ancestor_ element (if all have the same color), that has at least a 3:1 [contrast ratio](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) and a [distinguishing style][] both when the target element [gains focus][focused] and the target element is [hovered][]; or | ||
- a different background color, compared to the background color of the other descendant visible text nodes of the same _ancestor_ element (if all have the same background color), that has at least a 3:1 [contrast ratio](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) and a [distinguishing style][] both when the target element [gains focus][focused] and the target element is [hovered][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The terms "color" and "background color" are not defined. I imagine we'd want to use the definitions of "foreground color" and "background color" from #833?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expectation is currently unclear on at least two important points:
-
How to deal with short-/longhands? We inconsistently refer to both a shorthand (
border
) and a longhand (box-shadow
) property. I'm thinking we'd want to only ever refer to longhands as these are what conformant implementations of CSS must expand to anyway (https://drafts.csswg.org/css-cascade/#shorthand and https://drafts.csswg.org/cssom/#concept-declarations-specified-order). -
How to deal with semi-transparent border and box shadow colors in which case alpha compositing comes into play? One of the points about the definitions of "foreground color" and "background color" as defined by New rule: Text nodes have minimal contrast #833 was to avoid having to explicitly deal with alpha compositing at the rule level. If we refer to specific CSS properties, there's not really a way around this as I see it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The (foreground and background) color definitions in #833 might return multiple colors. Initially, I thought that would be a problem for this rule. But given that there is an assumption stating that if multiple colors are in use then color can't be a distinguishing factor then that problem goes away and I believe I can rewrite the expectation using #833 definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with using only longhand properties. Replaced border-color
by the corresponding longhand properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the comments so far. Approve probably when applied
Updated based on requested changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @joao-vicente was referring to @danistr , your input would be very much appreciated since you requested some changes.
From my side, just a couple of things that called my attention.
```html | ||
<html> | ||
<head> | ||
<title>Passed example 2 for rule be4d0c</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something, but why are the head and title elements needed for Passed example 2 and not for passed example 1. If there is the need to have specific styles, they could be added using the <style> element. I think this is what @WilcoFiers means here. We use to include only the HTML/CSS/JavaScript chunk of code that is necessary for the example to be interpreted and understood.
Requested changes made
With the PR w3c/wcag#1500 having been merged we are free to continue working this rule. I've updated it to expect that the styles are different in every state (hover or focused) and kept it as considering hue only for applicability (and color for expectation). @WilcoFiers @Jym77 @daniel-montalvo this is ready for another round of reviews. |
changes made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly suggesting to wait a bit until we decide how to handle states.
|
||
## Expectation 2 | ||
|
||
Either the test target does not match the [`:any-link` pseudo-class](https://drafts.csswg.org/selectors-4/#any-link-pseudo), or Expectation 1 holds for each [link history state][] with a **different hue**. | ||
|
||
## Expectation 3 | ||
|
||
Expectation 1 holds irrespectively of the test target being [focused][] or [hovered][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make it clear, I understand that this requires the 4 states to be valid, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
|
||
## Expectation 2 | ||
|
||
Either the test target does not match the [`:any-link` pseudo-class](https://drafts.csswg.org/selectors-4/#any-link-pseudo), or Expectation 1 holds for each [link history state][] with a **different hue**. | ||
|
||
## Expectation 3 | ||
|
||
Expectation 1 holds irrespectively of the test target being [focused][] or [hovered][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not fully clear how Expectation 2 and 3 work together.
I guess the intend is to have correct indication in the 8 possible states?
I suggest we wait until Thursday's join call to figure what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct once again. I split the "state handling" part of the rule into 2 different expectations to make it easier to read (given that the 2 dimensions link/visited and hover/focus are independent).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But with Expectation 3 referring only to Expectation 1, it is not clear that, say :visited
and :focus
should be OK.
(also, hover/focus are actually 2 independent dimensions, if we want one expectation per dimension, we could split them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that just as soon as I sent my message.
Probably the best way to handle this is move expectation 3 to expectation 2, and then have expectation 3 (link/visited) requesting expectation 2 to hold.
But I agree that it's best to leave this to after Thursday's meeting.
For each test target there exists at least one element with a [distinguishable style][] from each **non-link line text** elements for which one of the following is true: | ||
|
||
- the element is a [visible][] [inclusive descendant][] of the test target; or | ||
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. | |
- the element is an [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
For each test target there exists at least one element with a [distinguishable style][] from each **non-link line text** elements for which one of the following is true: | ||
|
||
- the element is a [visible][] [inclusive descendant][] of the test target; or | ||
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. | |
- the element is an [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
For each test target there exists at least one element with a [distinguishable style][] from each **non-link line text** elements for which one of the following is true: | ||
|
||
- the element is a [visible][] [inclusive descendant][] of the test target; or | ||
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the element is [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. | |
- the element is an [ancestor][] of the test target that is not simultaneously an [ancestor][] of the **non-link line text** elements. |
🙈 Gaaaaaah Github was trigger-happy today. Sorry. |
Co-authored-by: Jean-Yves Moyen <jym@siteimprove.com>
It just dawned on me that this rule doesn't yet seem like it would accept a difference in cursor presented as a distinguishing style. Consider the following example: <style>
a {
color: black;
}
a:hover {
text-decoration: none;
}
</style>
<p>Hello <a href="https://example.com">world</a></p> When the above link is hovered, the text decoration disappears, which is extremely common. When hovered, the link therefore doesn't seem like it would be considered distinguishable from the surrounding text by the rule. However, the cursor by default changes to a "pointer", prompting for an action and serving as a distinguishing feature for the link. Thoughts? |
The ACT rule never considered the pointer change as good enough…
If we do, we can basically stop testing on hover…
|
Well, it's still possible to do crazy things like this: <style>
a {
color: black;
}
a:hover {
text-decoration: none;
cursor: default;
}
</style>
<p>Hello <a href="https://example.com">world</a></p> Now the cursor doesn't change on hover 😔 Edit: This is already being discussed here: w3c/wcag#1761 |
New rule
Blocked: waiting for decision on how to handle states in rules
Need for Final Call:
This will require a 2 weeks Final Call << new rule, or substantial changes affecting a large number of test cases, if in doubt, use this. >>
Pull Request Etiquette
When creating PR:
develop
branch (left side).After creating PR:
Rule
,Definition
orChore
.How to Review And Approve