Skip to content

Commit 4ddf42a

Browse files
authored
Merge pull request #30 from github/kh-better-heading-structure
docs: add recent primer common patterns links and better heading structures
2 parents 2e4e839 + 4797dc1 commit 4ddf42a

File tree

7 files changed

+32
-23
lines changed

7 files changed

+32
-23
lines changed

docs/rules/accessibility/avoid-both-disabled-and-aria-disabled.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ HTML elements with `disabled` are ignored when a screen reader uses tab navigati
99

1010
This linter will raise when both `aria-disabled` and `disabled` are set on HTML elements that natively support `disabled` including `button`, `fieldset`, `input`, `optgroup`, `option`, `select`, and `textarea`.
1111

12-
### 👎 Examples of **incorrect** code for this rule:
12+
## Examples
13+
### **Incorrect** code for this rule 👎
1314

1415
```erb
1516
<button aria-disabled="true" disabled="true">
1617
<input aria-disabled="true" disabled="true">
1718
```
1819

19-
### 👍 Examples of **correct** code for this rule:
20+
### **Correct** code for this rule 👍
2021

2122
```erb
2223
<button disabled="true">

docs/rules/accessibility/iframe-has-title.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
`<iframe>` should have a unique title attribute that identifies the content. The title will help screen reader users determine whether to explore the frame in detail. If an `<iframe>` contains no meaningful content, hide it by setting `aria-hidden="true"`.
66

7-
### 👎 Examples of **incorrect** code for this rule:
7+
## Examples
8+
### **Incorrect** code for this rule 👎
89

910
```erb
1011
<iframe src="../welcome-video"></iframe>
1112
```
1213

13-
### 👍 Examples of **correct** code for this rule:
14+
### **Correct** code for this rule 👍
1415

1516
```erb
1617
<!-- good -->

docs/rules/accessibility/image-has-alt.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44

55
`<img>` should have an alt prop with meaningful text or an empty string for decorative images.
66

7-
Learn more at [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/).
7+
## Resources
88

9-
### 👎 Examples of **incorrect** code for this rule:
9+
- [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/)
10+
- [Primer: Alternative text for images](https://primer.style/design/accessibility/alternative-text-for-images)
11+
12+
## Examples
13+
### **Incorrect** code for this rule 👎
1014

1115
```erb
1216
<img src="logo.png">
1317
```
1418

15-
### 👍 Examples of **correct** code for this rule:
19+
### **Correct** code for this rule 👍
1620

1721
```erb
1822
<!-- good -->

docs/rules/accessibility/no-aria-label-misuse-counter.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@ This rule aims to discourage common misuse of the `aria-label` and `aria-labelle
66

77
### "Help! I'm trying to set a tooltip on a static element and this rule flagged it!"
88

9-
Please do not use tooltips on static elements. It is a highly discouraged, inaccessible pattern for the following reasons:
10-
11-
- Static elements are not tab-focusable so keyboard-only users will not be able to access the tooltip at all. (Note: setting `tabindex="0"` to force a generic element to be focusable is not a solution.)
12-
- It's likely that tooltip is inappropriate for your usecase to begin with. Tooltips are not accessible at all on mobile devices so if you're trying to convey critical information, use something else. Additionally, implementing tooltip as `aria-label` is rarely appropriate and has potential to cause accessibility issues for screen reader users.
13-
14-
If you've determined the tooltip content is not critical, simply remove it. If you determine the tooltip content is important to keep, we encourage you to reach out to a design or accessibility team who can assist in finding an alternate, non-tooltip pattern.
9+
Please do not use tooltips on static elements. It is a highly discouraged, inaccessible pattern.
10+
See [Primer: Tooltip alternatives](https://primer.style/design/accessibility/tooltip-alternatives) for what to do instead.
1511

1612
### Resources
1713

1814
- [w3c/aria Consider prohibiting author naming certain roles #833](https://github.com/w3c/aria/issues/833)
1915
- [Not so short note on aria-label usage - Big Table Edition](https://html5accessibility.com/stuff/2020/11/07/not-so-short-note-on-aria-label-usage-big-table-edition/)
2016
- [Your tooltips are bogus](https://heydonworks.com/article/your-tooltips-are-bogus/)
17+
- [Primer: Tooltip alternatives](https://primer.style/design/accessibility/tooltip-alternatives)
2118

2219
### Disclaimer
2320

2421
There are conflicting resources and opinions on what elements should support these naming attributes. For now, this rule will operate under a relatively simple heuristic aimed to minimize false positives. This may have room for future improvements. Learn more at [W3C Name Calcluation](https://w3c.github.io/aria/#namecalculation).
2522

26-
### 👎 Examples of **incorrect** code for this rule:
23+
### **Incorrect** code for this rule 👎
2724

2825
```erb
2926
<span class="tooltipped" aria-label="This is a tooltip">I am some text.</span>
@@ -41,7 +38,7 @@ There are conflicting resources and opinions on what elements should support the
4138
<h1 aria-label="This will override the page title completely">Page title</h1>
4239
```
4340

44-
### 👍 Examples of **correct** code for this rule:
41+
### **Correct** code for this rule 👍
4542

4643
```erb
4744
<button aria-label="Close">

docs/rules/accessibility/no-positive-tab-index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Learn more at:
99
- [A11yProject: Use the tabindex attribute](https://www.a11yproject.com/posts/how-to-use-the-tabindex-attribute/)
1010
- [Deque: Avoid using Tabindex with positive numbers](https://dequeuniversity.com/tips/tabindex-positive-numbers)
1111

12-
### 👎 Examples of **incorrect** code for this rule:
12+
## Examples
13+
### **Incorrect** code for this rule 👎
1314

1415
```erb
1516
<button tabindex="3"></button>
1617
<button tabindex="1"></button>
1718
```
1819

19-
### 👍 Examples of **correct** code for this rule:
20+
### **Correct** code for this rule 👍
2021

2122
```erb
2223
<!-- good -->

docs/rules/accessibility/no-redundant-image-alt.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
This rule does not discourage conveying the _medium_ of the image which may be considered important to help a user better understand the content.
88
For example, this rule will not flag terms including `screenshot`, `painting`, or `photograph`.
99

10-
Learn more at [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/).
10+
## Resources
1111

12-
### 👎 Examples of **incorrect** code for this rule:
12+
- [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/)
13+
- [Primer: Alternative text for images](https://primer.style/design/accessibility/alternative-text-for-images)
14+
15+
## Examples
16+
### **Incorrect** code for this rule 👎
1317

1418
```erb
1519
<img alt="picture of Mona Lisa" src="monalisa.png">
@@ -20,7 +24,7 @@ Learn more at [W3C WAI Images Tutorial](https://www.w3.org/WAI/tutorials/images/
2024
<img alt="image of a fluffy dog" src="monalisa.png">
2125
```
2226

23-
### 👍 Examples of **correct** code for this rule:
27+
### **Correct** code for this rule 👍
2428

2529
```erb
2630
<!-- good -->

docs/rules/accessibility/no-title-attribute-counter.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ If you are considering the`title` attribute to provide supplementary description
1212

1313
Use a `<title>` element instead of the `title` attribute, or an `aria-label`.
1414

15-
### Resources
15+
## Resources
1616

1717
- [TPGI: Using the HTML title attribute ](https://www.tpgi.com/using-the-html-title-attribute/)
1818
- [The Trials and Tribulations of the Title Attribute](https://www.24a11y.com/2017/the-trials-and-tribulations-of-the-title-attribute/)
1919

20-
### 👎 Examples of **incorrect** code for this rule:
20+
## Examples
21+
### **Incorrect** code for this rule 👎
2122

2223
```erb
2324
<a title="A home for all developers" href="github.com">GitHub</a>
@@ -27,7 +28,7 @@ Use a `<title>` element instead of the `title` attribute, or an `aria-label`.
2728
<a href="/" title="github.com">GitHub</a>
2829
```
2930

30-
### 👍 Examples of **correct** code for this rule:
31+
### **Correct** code for this rule 👍
3132

3233
```erb
3334
<a href="github.com" aria-describedby="description">GitHub</a>

0 commit comments

Comments
 (0)