-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
479 lines (467 loc) · 21.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Web Content Accessibility Guidelines (WCAG)</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav>
<ul>
<li><a href="#color-contrast">Color Contrast</a></li>
<li><a href="#alternative-text">Alternative Text</a></li>
<li><a href="#links">Links</a></li>
<li><a href="#labels">Labels</a></li>
<li><a href="#semantic-html">Semantic HTML</a></li>
<li><a href="#lists">Lists</a></li>
<li><a href="#headings">Headings</a></li>
<li><a href="#aria">ARIA</a></li>
<li><a href="#accessible-js">Accessible JavaScript</a></li>
<li><a href="#skip-nav">Skip Navigation</a></li>
</ul>
</nav>
<h1>Web Content Accessibility Guidelines (WCAG)</h1>
<p>
Web Content Accessibility Guidelines (WCAG) are a set of guidelines that
ensure that websites are accessible to all users, including those with
disabilities. The guidelines are divided into four principles:
Perceivable, Operable, Understandable, and Robust (POUR).
</p>
<div class="principles-container">
<div class="principle-box">
<h2>Perceivable:</h2>
<p>
Information and user interface components must be presentable to users
in ways they can perceive. This means that users must be able to
perceive the information being presented (it can't be invisible to all
of their senses) and that it must be presented in a way that they can
perceive it.
</p>
</div>
<div class="principle-box">
<h2>Operable:</h2>
<p>
User interface components and navigation must be operable. This means
that users must be able to operate the interface (the interface cannot
require interaction that a user cannot perform) and the interface must
be navigable (the interface cannot trap the user in a particular
section of the content).
</p>
</div>
<div class="principle-box">
<h2>Understandable:</h2>
<p>
Information and the operation of user interface must be
understandable. This means that users must be able to understand the
information as well as the operation of the user interface (the
content or operation cannot be beyond their understanding).
</p>
</div>
<div class="principle-box">
<h2>Robust:</h2>
<p>
Content must be robust enough that it can be interpreted reliably by a
wide variety of user agents, including assistive technologies. This
means that users must be able to access the content as technologies
advance (as technologies and user agents evolve, the content should
remain accessible).
</p>
</div>
</div>
<h2>WCAG Levels:</h2>
<p>
A level: Basic web accessibility features. This level addresses the most
basic web accessibility features.
</p>
<p>
AA level: Deals with the biggest and most common barriers for disabled
users. This level is generally the target for most websites.
</p>
<p>
AAA level: The highest and most complex level of web accessibility. This
level is typically not required for most websites as it is very difficult
to achieve.
</p>
<h2 id="color-contrast">Color Contrast</h2>
<p>
The contrast between the text color and the background color should be at
least 4.5:1 for normal text and 3:1 for large text.
</p>
<p>
You can easily check the contrast of your website using this
<a href="https://webaim.org/resources/contrastchecker/"
>contrast checker link</a
>.
</p>
<p>
Or you can use the contrast checker tool in the Chrome browser. Right
click on the text and select "Inspect". Then click on the "Contrast ratio"
tab.
</p>
<p class="example">
This is an example of good contrast. The text color is black, and the
background color is white.
<img
src="./image-2.png"
alt="picture of a contrast accessibility"
class="img"
/>
You can check the contrast of this text using the contrast checker tool or
Browser contrast checker.
</p>
<p class="bad-contrast bad-example">
This is an example of bad contrast. The text color is light gray, and the
background color is light gray.
<img
src="./image.png"
alt="picture of a contrast accessibility"
class="img"
/>
You can check the contrast of this text using the contrast checker tool or
Browser contrast checker.
</p>
<h2>Example Contrast Ratios:</h2>
<div class="contrast-example contrast-21-1">
Contrast ratio: 21:1 (Good contrast)
</div>
<div class="contrast-example contrast-7-1">
Contrast ratio: 7:1 (Good contrast)
</div>
<div class="contrast-example contrast-3-1">
Contrast ratio: 3:1 (Poor contrast)
</div>
<div class="contrast-example contrast-2-1">
Contrast ratio: 2:1 (Poor contrast)
</div>
<div class="contrast-example contrast-4-1">
Contrast ratio: 4:1 (Poor contrast)
</div>
<div class="contrast-example contrast-15-1">
Contrast ratio: 15:1 (Good contrast)
</div>
<div class="contrast-example contrast-8-1">
Contrast ratio: 8:1 (Good contrast)
</div>
<div class="contrast-example contrast-19-1">
Contrast ratio: 19:1 (Good contrast)
</div>
<h2 id="alternative-text">Alternative Text</h2>
<p>
Alternative text is a text description that can be added to an image's
HTML tag. This text is read by screen readers to describe the image to
visually impaired users. The alt text should be descriptive and provide
the same information as the image. If the image is purely decorative, the
alt text should be empty.
</p>
<p class="example">
Example of an image with alt text:
<img
src="./info.jpeg"
alt="A person using a screen reader to access a
website"
class="img"
/>
<code
><img src="./info.jpeg" alt="A person using a screen reader to access
a website" class="img" /></code
>
</p>
<p class="example">
Example of an image with empty alt text:
<img src="./decorative.jpeg" alt="" class="img" />
<code><img src="./decorative.jpeg" alt="" class="img" /></code>
</p>
<h2 id="links">Links</h2>
<p>
Links should be descriptive and provide information about the destination
of the link. Screen readers read out the link text to users, so it should
be clear and concise. Avoid using generic text like "click here" or "read
more" as it does not provide any context to the user.
</p>
<p class="example">
Example of a descriptive link:
<a href="https://www.w3.org/WAI/WCAG21/quickref/" class="link"
>WCAG Quick Reference</a
>
<code
><a href="https://www.w3.org/WAI/WCAG21/quickref/"
class="link">WCAG Quick Reference</a></code
>
</p>
<p class="bad-example">
Example of a non-descriptive link:
<a href="https://www.w3.org/WAI/WCAG21/quickref/" class="link"
>Click here</a
>
<code
><a href="https://www.w3.org/WAI/WCAG21/quickref/"
class="link">Click here</a></code
>
</p>
<h2 id="labels">Labels</h2>
<p>
Labels are used to describe form elements such as input fields,
checkboxes, radio buttons, and select dropdowns. Labels should be associated
with their corresponding form elements using the "for" attribute on the label
tag. This allows screen readers to read out the label when the form element is
focused. Labels should be descriptive and provide context to the user.
</p>
<p>
Best practices for using labels:
<ol>
<li>Always use a label for each form element to ensure accessibility.</li>
<li>Make sure the label is descriptive and provides enough context.</li>
<li>Use the "for" attribute to associate the label with the form element by matching the "for" attribute value with the "id" of the form element.</li>
<li>For checkboxes and radio buttons, place the label text to the right of the form element for better readability.</li>
<li>For select dropdowns, use a label to describe the purpose of the dropdown.</li>
</ol>
</p>
<p>
You can use the following HTML to associate a label with a form element:
<code><label for="name">Name:</label></code>
<code><input type="text" id="name" /></code>
</p>
<p>
You can also wrap the input field inside the label tag to associate them:
<code><label>Name: <input type="text" /></label></code>
</p>
<p class="example">
Example of a label associated with an input field:
<label for="name">Name:</label>
<input type="text" id="name" />
<code
><label for="name">Name:</label> <input type="text"
id="name" /></code
>
</p>
<p class="example">
Example of a label associated with a checkbox:
<label for="subscribe">Subscribe to newsletter</label>
<input type="checkbox" id="subscribe" />
<code
><label for="subscribe">Subscribe to newsletter</label>
<input type="checkbox" id="subscribe" /></code
>
</p>
<p class="example">
Example of a label associated with radio buttons:
<label for="gender-male">Male</label>
<input type="radio" id="gender-male" name="gender" value="male" />
<label for="gender-female">Female</label>
<input type="radio" id="gender-female" name="gender" value="female" />
<code
><label for="gender-male">Male</label> <input type="radio"
id="gender-male" name="gender" value="male" /> <label
for="gender-female">Female</label> <input type="radio"
id="gender-female" name="gender" value="female" /></code
>
</p>
<p class="example">
Example of a label associated with a select dropdown:
<label for="country">Country:</label>
<select id="country">
<option value="us">United States</option>
<option value="ca">Canada</option>
<option value="uk">United Kingdom</option>
</select>
<code
><label for="country">Country:</label> <select
id="country"> <option value="us">United
States</option> <option value="ca">Canada</option>
<option value="uk">United Kingdom</option> </select></code
>
</p>
<h2 id="semantic-html">Semantic HTML</h2>
<p>
Using semantic HTML elements helps screen readers and other assistive
technologies understand the structure of the content. Some common semantic
elements include headings, paragraphs, lists, and links. By using these
elements appropriately, you can improve the accessibility and
user experience of your website.
</p>
<p>
Here are some examples of semantic HTML elements:
<ul class="example">
<li><header> - Defines a header for a document or section.</li>
<li><nav> - Defines navigation links.</li>
<li><main> - Defines the main content of a document.</li>
<li><article> - Defines an article or blog post.</li>
<li><section> - Defines a section of a document.</li>
<li><aside> - Defines content aside from the main content.</li>
<li><footer> - Defines a footer for a document or section.</li>
</ul>
</p>
<p>
By using these elements, you can create a more accessible and
user-friendly website for all users. For example, screen readers can
navigate through the content more easily, and users with disabilities
can better understand the structure of the page. Additionally, search
engines can use semantic HTML to better understand and index your
content.
</p>
<p class="example">
Here is an example of how you can use semantic HTML elements to
structure your content:
<code>
<header><br/>
<h1>Web Content Accessibility Guidelines (WCAG)</h1><br/>
</header><br/>
<nav><br/>
<ul><br/>
<li><a href="#color-contrast">Color Contrast</a></li><br/>
<li><a href="#alternative-text">Alternative Text</a></li><br/>
<li><a href="#links">Links</a></li><br/>
<li><a href="#labels">Labels</a></li><br/>
</ul><br/>
</nav><br/>
<main><br/>
<h2>Perceivable:</h2><br/>
<p>Information and user interface components must be presentable to users in ways they can perceive.</p><br/>
</main><br/>
<footer><br/>
<p>Copyright © 2021 Your Company. All rights reserved.</p><br/>
</footer>
</code>
</p>
<p>
By using semantic HTML elements, you can create a more accessible and
user-friendly website that benefits all users. Remember to test your
website for accessibility and make any necessary adjustments to ensure
compliance with WCAG guidelines.
</p>
<h2 id="lists">Lists</h2>
<p>Any consecutive items in a list are separated by list item elements. The list item elements are defined by the <code><li></code> tag. The <code><ul></code> tag is used to create an unordered list, and the <code><ol></code> tag is used to create an ordered list. The <code><dl></code> tag is used to create a definition list.
</p>
<p>
Lists are a great way to organize content on your website and make it
more accessible to users. There are three main types of lists in HTML:
ordered lists, unordered lists, and definition lists.
</p>
<p>
Ordered lists are used to display a list of items in a specific order,
such as a numbered list. Unordered lists are used to display a list of
items without any specific order, such as a bulleted list. Definition
lists are used to display a list of terms and their definitions.
</p>
<p>
Here are some examples of lists in HTML:
<ul class="example">
<li>
Ordered List:
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</li>
<li>
Unordered List:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</li>
<li>
Definition List:
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
<dt>Term 3</dt>
<dd>Definition 3</dd>
</dl>
</li>
</ul>
</p>
<h2 id="headings">Headings</h2>
<p>
Headings are used to define the structure of a web page and provide
hierarchy to the content. There are six levels of headings in HTML,
ranging from <code><h1></code> (the most important) to
<code><h6></code> (the least important). Headings help users
navigate the content of a page and understand the relationship between
different sections.
</p>
<p>
Screen reader users navigate a web page by jumping between headings, so
it's important to use headings to create a logical structure for your
content. Headings should be used to introduce new sections of content and
provide context to the user. Only one <code><h1></code> should be used per page, and the other headings should follow a logical order. Apply hedings for structure, not for styling.
</p>
<p>
Here is an example of how headings can be used to structure a web page:
<code class="example">
<h1>Main Heading</h1><br/>
<h2>Subheading 1</h2><br/>
<p>Content goes here...</p><br/>
<h2>Subheading 2</h2><br/>
<p>Content goes here...</p><br/>
<h3>Sub-subheading 1</h3><br/>
<p>Content goes here...</p><br/>
<h3>Sub-subheading 2</h3><br/>
<p>Content goes here...</p>
</code>
</p>
<h2 id="aria">ARIA(Accessible Rich Internet Applications)</h2>
<p>ARIA provides a way to make web content and web applications more accessible to people with disabilities. It is a set of attributes that can be added to HTML elements to define their roles, states, and properties. ARIA is especially useful for dynamic content and interactive elements that are not natively accessible to screen readers and other assistive technologies.</p>
<p>Some common ARIA attributes include:</p>
<ul class="example">
<li><code>role</code> - Defines the role of an element (e.g., button, link, menu).</li>
<li><code>aria-label</code> - Provides a label for an element that is not visible on the screen.</li>
<li><code>aria-labelledby</code> - References the ID of another element that serves as the label for the current element.</li>
<li><code>aria-describedby</code> - References the ID of another element that provides a description for the current element.</li>
<li><code>aria-hidden</code> - Indicates whether an element is visible or hidden to screen readers.</li>
<li><code>aria-live</code> - Defines how live regions should be announced by screen readers.</li>
</ul>
<h3>ARIA Live Regions</h3>
<p>ARIA live regions are used to announce dynamic content changes to screen reader users. Live regions can be set to different levels of verbosity to control how and when the content is announced. There are three main values for the <code>aria-live</code> attribute:</p>
<ul class="example">
<li><code>off</code> - The content is not announced by the screen reader.</li>
<li><code>polite</code> - The content is announced when the user is idle (e.g., after completing a task).</li>
<li><code>assertive</code> - The content is announced immediately, interrupting the current screen reader output.</li>
</ul>
<p>By using ARIA attributes and live regions, you can enhance the accessibility of your web content and provide a better experience for users with disabilities. Remember to test your website with screen readers and other assistive technologies to ensure that it is fully accessible.</p>
<h2 id="accessible-js">Accessible JavaScript</h2>
<p>JavaScript is a powerful tool for creating interactive and dynamic web content, but it can also introduce accessibility barriers if not implemented correctly. Here are some best practices for creating accessible JavaScript:</p>
<ul class="example">
<li>Use semantic HTML elements to provide structure and context to your content.</li>
<li>Ensure that interactive elements are keyboard accessible and focusable.</li>
<li>Provide alternative text for images and other non-text content.</li>
<li>Use ARIA attributes to define roles, states, and properties of elements.</li>
<li>Avoid using JavaScript to change the page structure or content without user interaction.</li>
<li>Test your website with screen readers and other assistive technologies to ensure accessibility.</li>
</ul>
<h2 id="skip-nav">Skip Navigation</h2>
<p>Skip navigation links are hidden links that allow users to skip over repetitive content and navigate directly to the main content of a web page. Skip navigation links are especially useful for keyboard and screen reader users who may have difficulty navigating through long lists of links or menus.</p>
<p>Here is an example of a skip navigation link:
<code ><a href="#main-content" class="skip-link">Skip to main content</a> <br/>
.skip-link{
left:100%;
transform: translate(100%,0);
opacity:0;
}
</code>
</p>
<p>The skip navigation link should be the first focusable element on the page and should be hidden from sighted users until it receives focus. When the link is focused, it should become visible and allow users to jump directly to the main content of the page.</p>
<h2>Resources:</h2>
<p>
If you have any questions or need further assistance with web
accessibility, feel free to reach out to me. I'm here to help!
<a href="mailto:[email protected]">Click here to Contact me</a>
</p>
<ul>
<li>
<a href="https://www.w3.org/WAI/WCAG21/quickref/"
>WCAG Quick Reference</a
>
</li>
<li>
<a href="https://webaim.org/resources/contrastchecker/"
>WebAIM Contrast Checker</a
>
</li>
</body>
</html>