feat(curriculum): add interactive examples to aria hidden lesson (#62739)

This commit is contained in:
Aeeshaht
2025-10-14 01:10:26 +01:00
committed by GitHub
parent 13366a25d9
commit ff1ea23aa1

View File

@@ -5,7 +5,7 @@ challengeType: 19
dashedName: what-is-the-aria-hidden-attribute
---
# --description--
# --interactive--
If you ever need to display content while at the same time hiding it from people who use assistive technology, like screen readers, you can use the `aria-hidden` attribute.
@@ -24,13 +24,27 @@ Here's an example where we hide an icon from the accessibility tree by adding th
We only keep the text exposed to assistive technologies to avoid any confusion that may arise from the redundancy of having both an icon and text for the same purpose.
**NOTE**: This interactive example includes the Font Awesome CDN so you can see the gear icon displayed in the preview window.
:::interactive_editor
```html
<head>
<!-- Font Awesome CDN -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.0/css/all.min.css"
/>
</head>
<button>
<i class="fa-solid fa-gear" aria-hidden="true"></i>
<span class="label">Settings</span>
</button>
```
:::
You do not need to use `aria-hidden` when:
- The HTML element already has a `hidden` attribute.