Skip to content

Commit 5df991d

Browse files
fix(curriculum): add missing content to CSS Accessibility review (freeCodeCamp#58650)
Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
1 parent 5dbf506 commit 5df991d

File tree

2 files changed

+98
-4
lines changed

2 files changed

+98
-4
lines changed

curriculum/challenges/english/25-front-end-development/review-css-accessibility/671a955b74ab5588735800d1.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ Review the concepts below to prepare for the upcoming quiz.
1414
- **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.
1515
- **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.
1616

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
1834

1935
- **`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.
2036
- **`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.
3450
}
3551
```
3652

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+
3768
- **`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+
<p aria-hidden>This paragraph is visible for sighted users, but is hidden from assistive technology.</p>
73+
<p hidden>This paragraph is hidden from both sighted users and assistive technology.</p>
74+
```
75+
76+
## Accessibility Issue of the `placeholder` Attribute
3977

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.
4079

4180
# --assignment--
4281

curriculum/challenges/english/25-front-end-development/review-css/671a9a0a140c2b9d6a75629f.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,68 @@ Review the concepts below to prepare for the upcoming exam.
371371
- **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.
372372
- **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.
373373

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
375391

376392
- **`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.
377393
- **`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.
378394
- **`.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+
379425
- **`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+
<p aria-hidden>This paragraph is visible for sighted users, but is hidden from assistive technology.</p>
430+
<p hidden>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.
381436

382437
## Working with Different Attribute Selectors and Links
383438

0 commit comments

Comments
 (0)