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

Color contrast survey updates #1961

Merged
merged 13 commits into from
Nov 23, 2022
Merged
7 changes: 7 additions & 0 deletions __tests__/spelling-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
- testability
- focusability
- unitless
- luminance

# Parts of Unicode
- 000A
Expand Down Expand Up @@ -272,3 +273,9 @@
# Color values
- HSL
- hsl

# Variables used in definitions / descriptions
- A-lum-max
- A-lum-min
- B-lum-max
- B-lum-min
94 changes: 68 additions & 26 deletions _rules/text-contrast-afw4f7.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ acknowledgments:

This rule applies to any [visible][] character in a [text node][] that is a [child][] in the [flat tree][] of an [HTML element][], except if the [text node][] has an [ancestor][] in the [flat tree][] for which at least one of the following is true:

- **widget**: the ancestor is a [inheriting semantic][] `widget`; or
- **disabled widget**: the ancestor is a [inheriting semantic][] `widget` that is [disabled][]; or
- **disabled label**: the ancestor is used in the [accessible name][] of a [inheriting semantic][] `widget` that is [disabled][]; or
- **disabled group**: the ancestor has a [semantic role][] of `group` and is [disabled][].
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -102,11 +102,16 @@ This dark gray text has a contrast ratio between 12.6:1 and 5:1 on the white to
This light gray text has a contrast ratio between 13:1 and 5:1 on the background image.

```html
<p
style="color: #CCC; height:50px; padding-top:15px; background: #000 no-repeat -20px -20px url('/test-assets/contrast/black-hole.jpeg');"
>
Black hole sun
</p>
<style>
p {
color: #CCC;
height: 50px;
padding-top: 15px;
background: #000 no-repeat -20px -20px url('/test-assets/contrast/black-hole.jpeg');
text-shadow: 0px 0px 2px black;
tombrunet marked this conversation as resolved.
Show resolved Hide resolved
}
</style>
<p>Black hole sun</p>
```

#### Passed Example 4
Expand Down Expand Up @@ -169,6 +174,26 @@ This dark gray text has a contrast ratio of 12.6:1 on the white background in a
</script>
```

#### Passed Example 10

This text is part of a widget because it is a child of a `button` element. The text has the default
browser button text color on the default browser button background color. By default, this is black text on a
light gray background with a contrast ratio of 18.26:1
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

```html
<button>My button!</button>
```

#### Passed Example 11

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved
The text has the default browser text color on the default browser background color. By default, this is
black text on a white background with a contrast ratio of 21:1

```html
<div role="button">My button!</div>
```

### Failed

#### Failed Example 1
Expand Down Expand Up @@ -257,7 +282,7 @@ This semi-transparent gray text has a contrast ratio between 2.3:1 and 4.2:1 on

#### Failed Example 8

The first `p` element has a contrast ratio of 12.6:1. The second `p` element, which contains an example of the Helvetica font, has a contrast ratio of 3.5:1. Because this provides information, and not only for aesthetic purposes, this is not considered [purely decorative][].
The first `p` element has a contrast ratio of 12.6:1. The second `p` element, which contains an example of the Helvetica font, has a contrast ratio of 3.85:1. Because this provides information, and not only for aesthetic purposes, this is not considered [purely decorative][].
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

```html
<p style="color: #333; background: #FFF;">
Expand All @@ -268,6 +293,23 @@ The first `p` element has a contrast ratio of 12.6:1. The second `p` element, wh
</p>
```

#### Failed Example 9

This text is part of a widget because it is a child of a `button` element. The button text has a contrast
ratio of 3.85:1.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved
```html
<button style="color: #777; background: #EEE;">My button!</button>
```

#### Failed Example 10

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.
The button text has a contrast ratio of 3.85:1.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

```html
<div role="button" style="color: #777; background: #EEE;">My button!</div>
```

### Inapplicable

#### Inapplicable Example 1
Expand Down Expand Up @@ -316,22 +358,6 @@ This text not part of a [text node][].

#### Inapplicable Example 6

This text is part of a widget because it is a child of a `button` element.
tombrunet marked this conversation as resolved.
Show resolved Hide resolved

```html
<button>My button!</button>
```

#### Inapplicable Example 7

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.

```html
<div role="button">My button!</div>
```

#### Inapplicable Example 8

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element with `type="text"`.

```html
Expand All @@ -341,7 +367,7 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</label>
```

#### Inapplicable Example 9
#### Inapplicable Example 7

This text is part of a label of a [disabled][] widget, because it is in an element that is referenced by `aria-labelledby` from an element with `role="textbox"`.

Expand All @@ -359,7 +385,7 @@ This text is part of a label of a [disabled][] widget, because it is in an eleme
</div>
```

#### Inapplicable Example 10
#### Inapplicable Example 8

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element in a `fieldset` element with the `disabled` attribute.

Expand All @@ -372,7 +398,7 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</fieldset>
```

#### Inapplicable Example 11
#### Inapplicable Example 9

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element in an element with `role="group"` with the `aria-disabled="true"` attribute.

Expand All @@ -385,6 +411,22 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</div>
```

#### Inapplicable Example 10

This text is part of a [disabled][] widget because it is a child of a `button` element with the `disabled` attribute.
tombrunet marked this conversation as resolved.
Show resolved Hide resolved

```html
<button style="color: #777; background: #EEE;" disabled>My button!</button>
```

#### Inapplicable Example 11

This text is part of a [disabled][] widget because it is a child of an element with the `role` attribute set to `button` and with an `aria-disabled` attribute set to `true`.

```html
<div role="button" style="color: #777; background: #EEE;" aria-disabled="true">My button!</div>
```

[accessible name]: #accessible-name 'Definition of Accessible Name'
[ancestor]: https://dom.spec.whatwg.org/#concept-shadow-including-ancestor 'DOM, ancestor, 2020/07/23'
[assistive technology]: https://www.w3.org/TR/WCAG21/#dfn-assistive-technologies 'WCAG definition of Assistive Technologies'
Expand Down
78 changes: 58 additions & 20 deletions _rules/text-contrast-enhanced-09o5cg.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ acknowledgments:

This rule applies to any [visible][] character in a [text node][] that is a [child][] in the [flat tree][] of an [HTML element][], except if the [text node][] has an [ancestor][] in the [flat tree][] for which at least one of the following is true:

- **widget**: the ancestor is a [inheriting semantic][] `widget`; or
- **disabled widget**: the ancestor is a [inheriting semantic][] `widget` that is [disabled][]; or
- **disabled label**: the ancestor is used in the [accessible name][] of a [inheriting semantic][] `widget` that is [disabled][]; or
- **disabled group**: the ancestor has a [semantic role][] of `group` and is [disabled][].

Expand Down Expand Up @@ -164,6 +164,26 @@ This dark gray text has a contrast ratio of 12.6:1 on the white background in a
</script>
```

#### Passed Example 9

This text is part of a widget because it is a child of a `button` element. The text has the default
browser button text color on the default browser button background color. By default, this is black text on a
light gray background with a contrast ratio of 18.26:1

```html
<button>My button!</button>
```

#### Passed Example 10

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.
The text has the default browser text color on the default browser background color. By default, this is
black text on a white background with a contrast ratio of 21:1

Jym77 marked this conversation as resolved.
Show resolved Hide resolved
```html
<div role="button">My button!</div>
```

### Failed

#### Failed Example 1
Expand Down Expand Up @@ -283,6 +303,24 @@ The first `p` element has a contrast ratio of 12.6:1. The second `p` element, wh
</p>
```

#### Failed Example 11

This text is part of a widget because it is a child of a `button` element. The button text has a contrast ratio of 6.4:1.

```html
<button style="color: #555; background: #EEE;">My button!</button>
```

#### Failed Example 12

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.
The button text has a contrast
ratio of 6.4:1.

Jym77 marked this conversation as resolved.
Show resolved Hide resolved
```html
<div role="button" style="color: #555; background: #EEE;">My button!</div>
```

### Inapplicable

#### Inapplicable Example 1
Expand Down Expand Up @@ -331,22 +369,6 @@ This text not part of a [text node][].

#### Inapplicable Example 6

This text is part of a widget because it is a child of a `button` element.

```html
<button>My button!</button>
```

#### Inapplicable Example 7

This text is part of a widget because it is a child of an element with the `role` attribute set to `button`.

```html
<div role="button">My button!</div>
```

#### Inapplicable Example 8

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element with `type="text"`.

```html
Expand All @@ -356,7 +378,7 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</label>
```

#### Inapplicable Example 9
#### Inapplicable Example 7

This text is part of a label of a [disabled][] widget, because it is in an element that is referenced by `aria-labelledby` from an element with `role="textbox"`.

Expand All @@ -374,7 +396,7 @@ This text is part of a label of a [disabled][] widget, because it is in an eleme
</div>
```

#### Inapplicable Example 10
#### Inapplicable Example 8

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element in a `fieldset` element with the `disabled` attribute.

Expand All @@ -387,7 +409,7 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</fieldset>
```

#### Inapplicable Example 11
#### Inapplicable Example 9

This text is part of a label of a [disabled][] widget, because it is in a `label` element that is the label for an `input` element in an element with `role="group"` with the `aria-disabled="true"` attribute.

Expand All @@ -400,6 +422,22 @@ This text is part of a label of a [disabled][] widget, because it is in a `label
</div>
```

#### Inapplicable Example 10

This text is part of a [disabled][] widget because it is a child of a `button` element with the `disabled` attribute.
tombrunet marked this conversation as resolved.
Show resolved Hide resolved

```html
<button style="color: #777; background: #EEE;" disabled>My button!</button>
```

#### Inapplicable Example 11

This text is part of a [disabled][] widget because it is a child of an element with the `role` attribute set to `button` and with an `aria-disabled` attribute set to `true`.

```html
<div role="button" style="color: #777; background: #EEE;" aria-disabled="true">My button!</div>
```

[accessible name]: #accessible-name 'Definition of Accessible Name'
[ancestor]: https://dom.spec.whatwg.org/#concept-shadow-including-ancestor 'DOM, ancestor, 2020/07/23'
[assistive technology]: https://www.w3.org/TR/WCAG21/#dfn-assistive-technologies 'WCAG definition of Assistive Technologies'
Expand Down
6 changes: 5 additions & 1 deletion pages/glossary/highest-possible-contrast.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ unambiguous: true
objective: true
---

The highest value of the [contrast ratios](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) between two sets of colors.
The highest value of the [contrast ratios](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio) between two sets of colors (A and B).
To calculate the highest value, find the colors in each set with the largest and smallest
[relative luminance](https://www.w3.org/TR/WCAG21/#dfn-relative-luminance) (`A-lum-max`, `A-lum-min`, `B-lum-max`, `B-lum-min`). The
highest possible contrast is then the larger of the [contrast ratios](https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio)
of `A-lum-max` with `B-lum-min` versus `A-lum-min` with `B-lum-max`.
Jym77 marked this conversation as resolved.
Show resolved Hide resolved