You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: add languages to code blocks in marking guides (mdn#726)
__Additions:__
- Add lang to code block info strings in marking guides
__Changes:__
- incidental formatting md & code blocks
- Minor typo fix
- indent nested lists in md
Copy file name to clipboardExpand all lines: accessibility/tasks/html-css/aria/marking.md
+12-10
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ The aim of these tasks is to demonstrate an understanding of the techniques cove
4
4
5
5
## Task 1
6
6
7
-
In our first ARIA task, we present you with a section of non-semantic markup, which is obviously meant to be a list. Assuming you are not able to change the elements used, how can you allow screenreader users to recognize this as a list?
7
+
In our first ARIA task, we present you with a section of non-semantic markup, which is obviously meant to be a list. Assuming you are not able to change the elements used, how can you allow screenreader users to recognize this as a list?
8
8
9
9
The `list` and `listitem` roles are what you need here. The updated markup would look like so:
10
10
11
-
```
11
+
```html
12
12
<divrole="list">
13
13
<divrole="listitem">Pig</div>
14
14
<divrole="listitem">Gazelle</div>
@@ -32,21 +32,23 @@ Answers:
32
32
33
33
The finished HTML should look something like this:
34
34
35
-
```
35
+
```html
36
36
<formrole="search">
37
-
<input type="search" name="search"
38
-
aria-label="Search for your favorite content on our site">
37
+
<input
38
+
type="search"
39
+
name="search"
40
+
aria-label="Search for your favorite content on our site"
41
+
/>
39
42
</form>
40
43
```
41
44
42
45
## Task 3
43
-
For this final WAI-ARIA task, we return to an example we previously saw in the [CSS and JavaScript skilltest](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/CSS_and_JavaScript/Test_your_skills:_CSS_and_JavaScript_accessibility). As before, we have a simple app that presents a list of animal names. Clicking one of the animal names causes a further description of that animal to appear in a box below the list. Here, we are starting with a mouse- and keyboard-accessible version.
46
+
47
+
For this final WAI-ARIA task, we return to an example we previously saw in the [CSS and JavaScript skilltest](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/CSS_and_JavaScript/Test_your_skills:_CSS_and_JavaScript_accessibility). As before, we have a simple app that presents a list of animal names. Clicking one of the animal names causes a further description of that animal to appear in a box below the list. Here, we are starting with a mouse- and keyboard-accessible version.
44
48
45
49
The problem we have now is that when the DOM changes to show a new description, screenreaders cannot see what has changed. Can you update it so that description changes are announced by the screenreader?
46
50
47
51
There are two ways to solve this:
48
52
49
-
* Add an `aria-live=""` attribute to the animal-description `<div>` to turn it into a live region, so when its content changes, the updated content will be read out by a screenreader. The best value is probably `assertive`, which makes the screenreader read out the updated content as soon as it changed. `polite` means that the screenreader will wait until other descriptions have finished before it starts reading out the changed content.
50
-
* Add a `role="alert"` attribute to the animal-description `<div>`, to make it have alert box semantics. This has the same effect on the screenreader as setting `aria-live="assertive"` on it.
51
-
52
-
53
+
- Add an `aria-live=""` attribute to the animal-description `<div>` to turn it into a live region, so when its content changes, the updated content will be read out by a screenreader. The best value is probably `assertive`, which makes the screenreader read out the updated content as soon as it changed. `polite` means that the screenreader will wait until other descriptions have finished before it starts reading out the changed content.
54
+
- Add a `role="alert"` attribute to the animal-description `<div>`, to make it have alert box semantics. This has the same effect on the screenreader as setting `aria-live="assertive"` on it.
Copy file name to clipboardExpand all lines: accessibility/tasks/html-css/css/marking.md
+22-16
Original file line number
Diff line number
Diff line change
@@ -10,21 +10,22 @@ We'd like you to assume that the existing ruleset with the `a` selector is suppl
10
10
11
11
The CSS could look something like this:
12
12
13
-
```
13
+
```css
14
14
lia {
15
15
text-decoration: underline;
16
-
color: rgb(150,0,0);
16
+
color: rgb(150,0, 0);
17
17
}
18
18
19
-
li a:hover, li a:focus {
19
+
lia:hover,
20
+
lia:focus {
20
21
text-decoration: none;
21
-
color: rgb(255,0,0);
22
+
color: rgb(255,0, 0);
22
23
}
23
24
```
24
25
25
26
## Task 2
26
27
27
-
In this next task you are presented with a simple bit of content — just headings and paragraphs. There are accessibility issues with the colors and sizing of the text; we'd like you to:
28
+
In this next task you are presented with a simple bit of content — just headings and paragraphs. There are accessibility issues with the colors and sizing of the text; we'd like you to:
28
29
29
30
1. Explain what the problems are, and what the guidelines are that state the acceptable values for color and sizing.
30
31
2. Select new values for the color and font-size that fix the problem.
@@ -35,28 +36,33 @@ The answers:
35
36
36
37
1. (Q1) The problems are that first of all, the color contrast is not acceptable, as per WCAG criteria [1.4.3 (AA)](https://www.w3.org/TR/WCAG21/#contrast-minimum) and [1.4.6 (AAA)](https://www.w3.org/TR/WCAG21/#contrast-enhanced), and secondly, the text is sized using vw units, which means that it is not zoomable in most browsers. [WCAG 1.4.4 (AA)](https://www.w3.org/TR/WCAG21/#resize-text) states that text should be resizable.
37
38
2. (Qs 2 and 3) to fix the code, you need to
38
-
* Choose a much better contrasting set of background and foreground colors.
39
-
* Use some different units to size the text (such as rem or even px), or even implement something that uses a combination of vw and other units, if you want it resizable but still relative in part to the viewport size
39
+
40
+
- Choose a much better contrasting set of background and foreground colors.
41
+
- Use some different units to size the text (such as rem or even px), or even implement something that uses a combination of vw and other units, if you want it resizable but still relative in part to the viewport size
42
+
40
43
3. For testing:
41
-
* You can test color contrast using a tool such as [aXe](https://www.deque.com/axe/), The [Firefox Accessibility Inspector](https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector), or even a simple standalone web page tool like the [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/).
42
-
* For text resizing, you'd need to load the example in a browser and try to resize it. Resizing vw unit-sized text works in Safari, but not Firefox or Chromium-based browsers.
44
+
45
+
- You can test color contrast using a tool such as [aXe](https://www.deque.com/axe/), The [Firefox Accessibility Inspector](https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector), or even a simple standalone web page tool like the [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/).
46
+
- For text resizing, you'd need to load the example in a browser and try to resize it. Resizing vw unit-sized text works in Safari, but not Firefox or Chromium-based browsers.
43
47
44
48
For the updated code, something like this would work for the updated color scheme:
45
49
46
-
```
50
+
```css
47
51
main {
48
52
padding: 20px;
49
53
background-color: red;
50
54
}
51
55
52
-
h1, h2, p {
56
+
h1,
57
+
h2,
58
+
p {
53
59
color: black;
54
60
}
55
-
```
61
+
```
56
62
57
63
And something like this would work for the font sizing:
58
64
59
-
```
65
+
```css
60
66
h1 {
61
67
font-size: calc(2.5rem);
62
68
}
@@ -70,9 +76,9 @@ p {
70
76
}
71
77
```
72
78
73
-
Or this, if you want to do something a bit cleverer that gives you resizable viewport-relative units:
79
+
Or this, if you want to do something a bit cleverer that gives you resizable viewport-relative units:
74
80
75
-
```
81
+
```css
76
82
h1 {
77
83
font-size: calc(1.5vw+1rem);
78
84
}
@@ -97,7 +103,7 @@ Answers:
97
103
1. To begin with, you'll need to add `tabindex="0"` to the list items to make them focusable via the keyboard.
98
104
2. Then you'll need to add in another event listener inside the `forEach()` loop, to make the code respond to keys being pressed while the list items are selected. It is probably a good idea to make it respond to a specific key, such as "Enter", in which case something like the following is probably acceptable:
Copy file name to clipboardExpand all lines: accessibility/tasks/html-css/html/marking.md
+78-48
Original file line number
Diff line number
Diff line change
@@ -8,41 +8,48 @@ In this task we will test your understanding of text semantics, and why they are
8
8
9
9
The given text is a simple information panel with action buttons:
10
10
11
-
```
12
-
<font size="7">Need help?</font>
13
-
<br><br>
14
-
If you have any problems with our products, our support center can offer you all the help you need, whether you want:
15
-
<br><br>
11
+
```html
12
+
<fontsize="7">Need help?</font> <br /><br />
13
+
If you have any problems with our products, our support center can offer you all
14
+
the help you need, whether you want:
15
+
<br /><br />
16
16
1. Advice choosing a new product
17
-
<br>
17
+
<br />
18
18
2. Tech support on an existing product
19
-
<br>
19
+
<br />
20
20
3. Refund and cancellation assistance
21
-
<br><br>
21
+
<br /><br />
22
22
<fontsize="5">Contact us now</font>
23
-
<br><br>
23
+
<br /><br />
24
24
Our help center contains live chat, e-mail addresses, and phone numbers.
25
-
<br><br>
25
+
<br /><br />
26
26
<divclass="button">Find Contact Details</div>
27
-
<br><br>
27
+
<br /><br />
28
28
<fontsize="5">Find out answers</font>
29
-
<br><br>
30
-
Our Forums section contains a large knowledge base of searchable previously asked questions, and you can always ask a new question if you can't find the answer you're looking for.
31
-
<br><br>
29
+
<br /><br />
30
+
Our Forums section contains a large knowledge base of searchable previously
31
+
asked questions, and you can always ask a new question if you can't find the
32
+
answer you're looking for.
33
+
<br /><br />
32
34
<divclass="button">Access forums</div>
33
35
```
34
36
35
37
But of course, this is terrible for semantics and accessibility. A much better set of markup would look like so:
36
38
37
-
```
39
+
```html
38
40
<h2>Need help?</h2>
39
41
40
-
<p>If you have any problems with our products, our support center can offer you all the help you need, whether you want:</p>
42
+
<p>
43
+
If you have any problems with our products, our support center can offer you
44
+
all the help you need, whether you want:
45
+
</p>
46
+
41
47
<ul>
42
48
<li>Advice choosing a new product</li>
43
49
<li>Tech support on an existing product</li>
44
50
<li>Refund and cancellation assistance</li>
45
51
</ul>
52
+
46
53
<h3>Contact us now</h3>
47
54
48
55
<p>Our help center contains live chat, e-mail addresses, and phone numbers.</p>
@@ -51,7 +58,11 @@ But of course, this is terrible for semantics and accessibility. A much better s
51
58
52
59
<h3>Find out answers</h3>
53
60
54
-
<p>Our Forums section contains a large knowledge base of searchable previously asked questions, and you can always ask a new question if you can't find the answer you're looking for.</p>
61
+
<p>
62
+
Our Forums section contains a large knowledge base of searchable previously
63
+
asked questions, and you can always ask a new question if you can't find the
64
+
answer you're looking for.
65
+
</p>
55
66
56
67
<button>Access forums</button>
57
68
```
@@ -62,6 +73,7 @@ You can get a couple of extra marks for:
62
73
2. Using an unordered list, not an ordered list — the list of items doesn't really need to be in any order.
63
74
64
75
## Task 2
76
+
65
77
In the second task, you have a form containing three input fields. You need to:
66
78
67
79
1. Semantically associate the input with their labels.
@@ -76,29 +88,29 @@ This is fairly simple, especially if you have previously worked through our [Web
76
88
77
89
Your answer should end up looking something like this:
78
90
79
-
```
91
+
```html
80
92
<form>
81
93
<fieldset>
82
-
<legend>Personal data</legend>
94
+
<legend>Personal data</legend>
83
95
<ul>
84
96
<li>
85
97
<labelfor="name">Name</label>
86
-
<input type="text" name="name" id="name">
98
+
<inputtype="text"name="name"id="name" />
87
99
</li>
88
100
<li>
89
101
<labelfor="age">Age</label>
90
-
<input type="number" name="age" id="age">
102
+
<inputtype="number"name="age"id="age" />
91
103
</li>
92
104
<li>
93
105
<labelfor="email">Email address</label>
94
-
<input type="email" name="email" id="email">
106
+
<inputtype="email"name="email"id="email" />
95
107
</li>
96
108
</ul>
97
109
</fieldset>
98
110
</form>
99
111
```
100
112
101
-
# Task 3
113
+
##Task 3
102
114
103
115
In this task you are required to turn all the information links in the paragraph into good, accessible links.
104
116
@@ -108,14 +120,26 @@ In this task you are required to turn all the information links in the paragraph
108
120
109
121
Initially the paragraph looks like this:
110
122
111
-
```
112
-
<p>For more information about our activities, check out our fundraising page (<a href="/fundraising">click here</a>), education page (<a href="/education">click here</a>), sponsorship pack (<a href="/resources/sponsorship.pdf">click here</a>), and assessment sheets (<a href="/resources/assessments.docx">click here</a>).</p>
123
+
```html
124
+
<p>
125
+
For more information about our activities, check out our fundraising page (
@@ -127,31 +151,37 @@ In our final HTML accessibility task, you are given a simple image gallery, whic
127
151
128
152
So, on to the answers:
129
153
130
-
1. The header image is decorative, so doesn't really need alt text. The best solution if you are going to use decorative HTML images is to put `alt=""`, so a screenreader will just read out nothing — rather than a description, or the image file name. It is not part of the content.
154
+
1. The header image is decorative, so doesn't really need alt text. The best solution if you are going to use decorative HTML images is to put `alt=""`, so a screenreader will just read out nothing — rather than a description, or the image file name. It is not part of the content.
131
155
2. The gallery images need alt text, and they are part of the content. The updated HTML could look something like this:
132
156
133
-
```
134
-
<header>
135
-
<img src="images/star.png" alt="">
136
-
<h1>Groovy images</h1>
137
-
</header>
138
-
<main>
139
-
<img src="images/teapot.jpg" alt="a black teapot placed on a shelf just inside a window">
140
-
<img src="images/football.jpg" alt="A black and white round panelled ball">
141
-
</main>
142
-
```
157
+
```html
158
+
<header>
159
+
<imgsrc="images/star.png"alt="" />
160
+
<h1>Groovy images</h1>
161
+
</header>
162
+
<main>
163
+
<img
164
+
src="images/teapot.jpg"
165
+
alt="a black teapot placed on a shelf just inside a window"
166
+
/>
167
+
<img
168
+
src="images/football.jpg"
169
+
alt="A black and white round panelled ball"
170
+
/>
171
+
</main>
172
+
```
143
173
144
174
3. It would be arguable better to implement the background header image using CSS background images. To do this, you would remove the following line:
145
175
146
-
```
147
-
<img src="images/star.png" alt="A star that I use to decorate my page">
148
-
```
176
+
```html
177
+
<imgsrc="images/star.png"alt="A star that I use to decorate my page" />
0 commit comments