Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update navigation-has-label docs #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/rules/accessibility/navigation-has-label.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Rule Details

This rule enforces that a navigation landmark (a `<nav>` or a `role="navigation"`) has an accessible name. This rule is helpful to enforce for sites (like GitHub) where multiple navigation is common.
This rule enforces that a navigation landmark (a `<nav>` or a `role="navigation"`) has an accessible name. This rule is helpful for sites (like GitHub) where multiple navigation elements is common.

The navigation landmark element should have an `aria-label` attribute, or `aria-labelledby` to distinguish it from other elements.
An accessible name ensures that one can distinguish between multiple navigation elements.

If the navigation area begins with a heading, use the heading to label the navigation element using the `aria-labelledby` attribute. If there is no heading, then you may set `aria-label`. Make sure to format the text the same way you would visual text (Related: [aria-label is well formatted](./aria-label-is-well-formatted.md)).

## Resources

Expand All @@ -24,7 +26,15 @@ The navigation landmark element should have an `aria-label` attribute, or `aria-

```erb
<!-- correct -->
<nav aria-labelledby="title_id"t>
<h1 id="title_id">This is a text</h1>
<nav aria-labelledby="title_id">
<h1 id="title_id">Setings</h1>
...
</nav>
```

```erb
<!-- correct -->
<nav aria-label="Repos">
...
</nav>
```