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
Copy file name to clipboardExpand all lines: curriculum/challenges/english/25-front-end-development/review-css-accessibility/671a955b74ab5588735800d1.md
+41-2Lines changed: 41 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,23 @@ Review the concepts below to prepare for the upcoming quiz.
14
14
-**WebAIM's Color Contrast Checker**: This online tool allows you to input the foreground and background colors of your design and instantly see if they meet the Web Content Accessibility Guidelines (WCAG) standards.
15
15
-**TPGi Colour Contrast Analyzer**: This is a free color contrast checker that allows you to check if your websites and apps meet the Web Content Accessibility Guidelines (WCAG) standards. This tool also comes with a Color Blindness Simulator feature which allows you to see what your website or app looks like for people with color vision issues.
16
16
17
-
## Best Practices With CSS and Accessibility
17
+
## Accessibility Tree
18
+
19
+
Accessibility tree is a structure used by assistive technologies, such as screen readers, to interpret and interact with the content on a webpage.
20
+
21
+
## `max()` Function
22
+
23
+
The **max()** function returns the largest of a set of comma-separated values:
24
+
25
+
```css
26
+
img {
27
+
width: max(250px, 25vw);
28
+
}
29
+
```
30
+
31
+
In the above example, the width of the image will be 250px if the viewport width is less than 1000 pixels. If the viewport width is greater than 1000 pixels, the width of the image will be 25vw. This is because 25vw is equal to 25% of the viewport width.
32
+
33
+
## Best Practices with CSS and Accessibility
18
34
19
35
-**`display: none;`**: Using `display: none;` means that screen readers and other assistive technologies won't be able to access this content, as it is not included in the accessibility tree. Therefore, it is important to use this method only when you want to completely remove content from both visual presentation and accessibility.
20
36
-**`visibility: hidden;`**: This property and value hides the content visually but keeps it in the document flow, meaning it still occupies space on the page. These elements will also no longer be read by screen readers because they will have been removed from the accessibility tree.
@@ -34,9 +50,32 @@ Review the concepts below to prepare for the upcoming quiz.
34
50
}
35
51
```
36
52
53
+
-**`scroll-behavior: smooth;`**: This property and value enables a smooth scrolling behavior.
54
+
-**`prefers-reduced-motion` feature**: This is a media feature that can be used to detect the user's animation preference.
55
+
56
+
```css
57
+
@media (prefers-reduced-motion: no-preference) {
58
+
* {
59
+
scroll-behavior: smooth;
60
+
}
61
+
}
62
+
```
63
+
64
+
In the above example, smooth scrolling is enabled if the user doesn't have animation preference set on their device.
65
+
66
+
## Hiding Content with HTML Attributes
67
+
37
68
-**`aria-hidden` attribute**: Used to hide an element from people using assistive technology such as screen readers. For example, this can be used to hide decorative images that do not provide any meaningful content.
38
-
-**`hidden` Attribute**: This attribute is supported by most modern browsers and hides content both visually and from the accessibility tree. It can be easily toggled with JavaScript.
69
+
-**`hidden` attribute**: This attribute is supported by most modern browsers and hides content both visually and from the accessibility tree. It can be easily toggled with JavaScript.
70
+
71
+
```html
72
+
<paria-hidden>This paragraph is visible for sighted users, but is hidden from assistive technology.</p>
73
+
<phidden>This paragraph is hidden from both sighted users and assistive technology.</p>
74
+
```
75
+
76
+
## Accessibility Issue of the `placeholder` Attribute
39
77
78
+
Using placeholder text is not great for accessibility. Too often, users confuse the placeholder text with an actual input value - they think there is already a value in the input.
Copy file name to clipboardExpand all lines: curriculum/challenges/english/25-front-end-development/review-css/671a9a0a140c2b9d6a75629f.md
+57-2Lines changed: 57 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -371,13 +371,68 @@ Review the concepts below to prepare for the upcoming exam.
371
371
-**WebAIM's Color Contrast Checker**: This online tool allows you to input the foreground and background colors of your design and instantly see if they meet the Web Content Accessibility Guidelines (WCAG) standards.
372
372
-**TPGi Colour Contrast Analyzer**: This is a free color contrast checker that allows you to check if your websites and apps meet the Web Content Accessibility Guidelines (WCAG) standards. This tools also comes with a Color Blindness Simulator feature which allows you to see what your website or app looks like for people with color vision issues.
373
373
374
-
## Best Practices With CSS and Accessibility
374
+
## Accessibility Tree
375
+
376
+
Accessibility tree is a structure used by assistive technologies, such as screen readers, to interpret and interact with the content on a webpage.
377
+
378
+
## `max()` Function
379
+
380
+
The **max()** function returns the largest of a set of comma-separated values:
381
+
382
+
```css
383
+
img {
384
+
width: max(250px, 25vw);
385
+
}
386
+
```
387
+
388
+
In the above example, the width of the image will be 250px if the viewport width is less than 1000 pixels. If the viewport width is greater than 1000 pixels, the width of the image will be 25vw. This is because 25vw is equal to 25% of the viewport width.
389
+
390
+
## Best Practices with CSS and Accessibility
375
391
376
392
-**`display: none;`**: Using `display: none;` means that screen readers and other assistive technologies won't be able to access this content, as it is not included in the accessibility tree. Therefore, it is important to use this method only when you want to completely remove content from both visual presentation and accessibility.
377
393
-**`visibility: hidden;`**: This property and value hides the content visually but keeps it in the document flow, meaning it still occupies space on the page. These elements will also no longer be read by screen readers because they will have been removed from the accessibility tree.
378
394
-**`.sr-only` CSS class**: This is a common technique used to visually hide content while keeping it accessible to screen readers.
395
+
396
+
```css
397
+
.sr-only {
398
+
position: absolute;
399
+
width: 1px;
400
+
height: 1px;
401
+
padding: 0;
402
+
margin: -1px;
403
+
overflow: hidden;
404
+
clip: rect(0, 0, 0, 0);
405
+
white-space: nowrap;
406
+
border: 0;
407
+
}
408
+
```
409
+
410
+
-**`scroll-behavior: smooth;`**: This property and value enables a smooth scrolling behavior.
411
+
-**`prefers-reduced-motion` feature**: This is a media feature that can be used to detect the user's animation preference.
412
+
413
+
```css
414
+
@media (prefers-reduced-motion: no-preference) {
415
+
* {
416
+
scroll-behavior: smooth;
417
+
}
418
+
}
419
+
```
420
+
421
+
In the above example, smooth scrolling is enabled if the user doesn't have animation preference set on their device.
422
+
423
+
## Hiding Content with HTML Attributes
424
+
379
425
-**`aria-hidden` attribute**: Used to hide an element from people using assistive technology such as screen readers. For example, this can be used to hide decorative images that do not provide any meaningful content.
380
-
-**`hidden` Attribute**: This attribute is supported by most modern browsers and hides content both visually and from the accessibility tree. It can be easily toggled with JavaScript.
426
+
-**`hidden` attribute**: This attribute is supported by most modern browsers and hides content both visually and from the accessibility tree. It can be easily toggled with JavaScript.
427
+
428
+
```html
429
+
<paria-hidden>This paragraph is visible for sighted users, but is hidden from assistive technology.</p>
430
+
<phidden>This paragraph is hidden from both sighted users and assistive technology.</p>
431
+
```
432
+
433
+
## Accessibility Issue of the `placeholder` Attribute
434
+
435
+
Using placeholder text is not great for accessibility. Too often, users confuse the placeholder text with an actual input value - they think there is already a value in the input.
381
436
382
437
## Working with Different Attribute Selectors and Links
0 commit comments