Skip to content

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

Open
wants to merge 293 commits into
base: develop
Choose a base branch
from

Conversation

carlosapaduarte
Copy link
Member

@carlosapaduarte carlosapaduarte commented Nov 7, 2019

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:

  • Make sure you requesting to pull a branch (right side) to the develop branch (left side).

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Close the issue that the PR resolves (and make sure the issue is referenced in the top of this comment)
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.
  • Make sure to also review the proposed Final Call period. In case of disagreement, the longer period wins.

@carlosapaduarte carlosapaduarte added the Rule Use this label for a new rule that does not exist already label Nov 7, 2019
@ShadowBB ShadowBB changed the title Create inline_link_in_paragraph_is_distinguishable_ be4d0c.md [WIP] New Rule: inline link in paragraph is distinguishable be4d0c Nov 7, 2019
@carlosapaduarte carlosapaduarte changed the title [WIP] New Rule: inline link in paragraph is distinguishable be4d0c New Rule: inline link in paragraph is distinguishable be4d0c Nov 7, 2019
@ShadowBB ShadowBB requested a review from danistr November 7, 2019 13:47
Copy link
Contributor

@kasperisager kasperisager left a 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`,
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

@WilcoFiers WilcoFiers left a 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
Copy link
Member

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.

Copy link
Member Author

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".

Copy link
Member Author

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][]
Copy link
Member

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.

Copy link
Member Author

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][]
Copy link
Member

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.

Copy link
Member Author

@carlosapaduarte carlosapaduarte Nov 19, 2019

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.
Copy link
Member

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.

Copy link
Collaborator

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?

Copy link
Contributor

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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Collaborator

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
Copy link
Member

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 ameta> 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.

Copy link
Member Author

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

@carlosapaduarte carlosapaduarte dismissed stale reviews from WilcoFiers and kasperisager November 26, 2019 11:09

Rule updated based on changes requested

Copy link
Collaborator

@DagfinnRomen DagfinnRomen left a comment

Choose a reason for hiding this comment

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

Some editorials.

```

### Inapplicable
Copy link
Collaborator

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
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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][].
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Collaborator

@danistr danistr left a 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

@carlosapaduarte carlosapaduarte dismissed kasperisager’s stale review January 11, 2020 16:37

Updated based on requested changes

@daniel-montalvo daniel-montalvo self-requested a review January 20, 2020 13:22
Copy link
Collaborator

@daniel-montalvo daniel-montalvo left a 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
Passed example 2 for rule be4d0c
Copy link
Collaborator

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

Hello world

'>
<style>
  a {
    color: black;
  }

  a:hover {
    text-decoration: none;
  }
style>

<p>Hello <a href="https://example.com">worlda>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?

@Jym77
Copy link
Collaborator

Jym77 commented Jun 25, 2021 via email

@kasperisager
Copy link
Contributor

kasperisager commented Jun 25, 2021

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">worlda>p>

Now the cursor doesn't change on hover 😔

Edit: This is already being discussed here: w3c/wcag#1761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Blocked by another PR/Issue Rule Use this label for a new rule that does not exist already
Projects
None yet
Development

Successfully merging this pull request may close these issues.