Skip to content

Commit 5c24cf4

Browse files
authored
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
1 parent 88fa9dd commit 5c24cf4

File tree

26 files changed

+699
-487
lines changed

26 files changed

+699
-487
lines changed

accessibility/tasks/html-css/aria/marking.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ The aim of these tasks is to demonstrate an understanding of the techniques cove
44

55
## Task 1
66

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?
88

99
The `list` and `listitem` roles are what you need here. The updated markup would look like so:
1010

11-
```
11+
```html
1212
<div role="list">
1313
<div role="listitem">Pig</div>
1414
<div role="listitem">Gazelle</div>
@@ -32,21 +32,23 @@ Answers:
3232

3333
The finished HTML should look something like this:
3434

35-
```
35+
```html
3636
<form role="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+
/>
3942
</form>
4043
```
4144

4245
## 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.
4448

4549
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?
4650

4751
There are two ways to solve this:
4852

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.

accessibility/tasks/html-css/css/marking.md

+22-16
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ We'd like you to assume that the existing ruleset with the `a` selector is suppl
1010

1111
The CSS could look something like this:
1212

13-
```
13+
```css
1414
li a {
1515
text-decoration: underline;
16-
color: rgb(150,0,0);
16+
color: rgb(150, 0, 0);
1717
}
1818

19-
li a:hover, li a:focus {
19+
li a:hover,
20+
li a:focus {
2021
text-decoration: none;
21-
color: rgb(255,0,0);
22+
color: rgb(255, 0, 0);
2223
}
2324
```
2425

2526
## Task 2
2627

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:
2829

2930
1. Explain what the problems are, and what the guidelines are that state the acceptable values for color and sizing.
3031
2. Select new values for the color and font-size that fix the problem.
@@ -35,28 +36,33 @@ The answers:
3536

3637
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.
3738
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+
4043
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.
4347

4448
For the updated code, something like this would work for the updated color scheme:
4549

46-
```
50+
```css
4751
main {
4852
padding: 20px;
4953
background-color: red;
5054
}
5155

52-
h1, h2, p {
56+
h1,
57+
h2,
58+
p {
5359
color: black;
5460
}
55-
```
61+
```
5662

5763
And something like this would work for the font sizing:
5864

59-
```
65+
```css
6066
h1 {
6167
font-size: calc(2.5rem);
6268
}
@@ -70,9 +76,9 @@ p {
7076
}
7177
```
7278

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:
7480

75-
```
81+
```css
7682
h1 {
7783
font-size: calc(1.5vw + 1rem);
7884
}
@@ -97,7 +103,7 @@ Answers:
97103
1. To begin with, you'll need to add `tabindex="0"` to the list items to make them focusable via the keyboard.
98104
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:
99105

100-
```
106+
```css
101107
item.addEventListener('keyup', function(e) {
102108
if(e.key === 'Enter') {
103109
handleSelection(e);

accessibility/tasks/html-css/html/marking.md

+78-48
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,48 @@ In this task we will test your understanding of text semantics, and why they are
88

99
The given text is a simple information panel with action buttons:
1010

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+
<font size="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 />
1616
1. Advice choosing a new product
17-
<br>
17+
<br />
1818
2. Tech support on an existing product
19-
<br>
19+
<br />
2020
3. Refund and cancellation assistance
21-
<br><br>
21+
<br /><br />
2222
<font size="5">Contact us now</font>
23-
<br><br>
23+
<br /><br />
2424
Our help center contains live chat, e-mail addresses, and phone numbers.
25-
<br><br>
25+
<br /><br />
2626
<div class="button">Find Contact Details</div>
27-
<br><br>
27+
<br /><br />
2828
<font size="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 />
3234
<div class="button">Access forums</div>
3335
```
3436

3537
But of course, this is terrible for semantics and accessibility. A much better set of markup would look like so:
3638

37-
```
39+
```html
3840
<h2>Need help?</h2>
3941

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+
4147
<ul>
4248
<li>Advice choosing a new product</li>
4349
<li>Tech support on an existing product</li>
4450
<li>Refund and cancellation assistance</li>
4551
</ul>
52+
4653
<h3>Contact us now</h3>
4754

4855
<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
5158

5259
<h3>Find out answers</h3>
5360

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>
5566

5667
<button>Access forums</button>
5768
```
@@ -62,6 +73,7 @@ You can get a couple of extra marks for:
6273
2. Using an unordered list, not an ordered list — the list of items doesn't really need to be in any order.
6374

6475
## Task 2
76+
6577
In the second task, you have a form containing three input fields. You need to:
6678

6779
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
7688

7789
Your answer should end up looking something like this:
7890

79-
```
91+
```html
8092
<form>
8193
<fieldset>
82-
<legend>Personal data</legend>
94+
<legend>Personal data</legend>
8395
<ul>
8496
<li>
8597
<label for="name">Name</label>
86-
<input type="text" name="name" id="name">
98+
<input type="text" name="name" id="name" />
8799
</li>
88100
<li>
89101
<label for="age">Age</label>
90-
<input type="number" name="age" id="age">
102+
<input type="number" name="age" id="age" />
91103
</li>
92104
<li>
93105
<label for="email">Email address</label>
94-
<input type="email" name="email" id="email">
106+
<input type="email" name="email" id="email" />
95107
</li>
96108
</ul>
97109
</fieldset>
98110
</form>
99111
```
100112

101-
# Task 3
113+
## Task 3
102114

103115
In this task you are required to turn all the information links in the paragraph into good, accessible links.
104116

@@ -108,14 +120,26 @@ In this task you are required to turn all the information links in the paragraph
108120

109121
Initially the paragraph looks like this:
110122

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 (
126+
<a href="/fundraising">click here</a>), education page (
127+
<a href="/education">click here</a>), sponsorship pack (
128+
<a href="/resources/sponsorship.pdf">click here</a>), and assessment sheets (
129+
<a href="/resources/assessments.docx">click here</a>).
130+
</p>
113131
```
114132

115133
But you should update it to something like this:
116134

117-
```
118-
<p>For more information about our activities, check out our <a href="/fundraising">fundraising page</a>, <a href="/education">education page</a>, <a href="/resources/sponsorship.pdf">sponsorship pack (PDF, 8MB)</a>, and <a href="/resources/assessments.docx">assessment sheets (Word document)</a>.</p>
135+
```html
136+
<p>
137+
For more information about our activities, check out our
138+
<a href="/fundraising">fundraising page</a>,
139+
<a href="/education">education page</a>,
140+
<a href="/resources/sponsorship.pdf">sponsorship pack (PDF, 8MB)</a>, and
141+
<a href="/resources/assessments.docx">assessment sheets (Word document)</a>.
142+
</p>
119143
```
120144

121145
## Task 4
@@ -127,31 +151,37 @@ In our final HTML accessibility task, you are given a simple image gallery, whic
127151

128152
So, on to the answers:
129153

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.
131155
2. The gallery images need alt text, and they are part of the content. The updated HTML could look something like this:
132156

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+
<img src="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+
```
143173

144174
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:
145175

146-
```
147-
<img src="images/star.png" alt="A star that I use to decorate my page">
148-
```
176+
```html
177+
<img src="images/star.png" alt="A star that I use to decorate my page" />
178+
```
149179

150-
And add in a CSS rule along these lines:
180+
And add in a CSS rule along these lines:
151181

152-
```
153-
h1 {
154-
background: url(images/star.png) no-repeat left;
155-
padding-left: 50px;
156-
}
157-
```
182+
```css
183+
h1 {
184+
background: url(images/star.png) no-repeat left;
185+
padding-left: 50px;
186+
}
187+
```

0 commit comments

Comments
 (0)