← Community home

How do you identify the current navigation link?

Community › Forums › Links & Navigation › How do you identify the current navigation link?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #188

    A menu needs to identify the current page for both visual and nonvisual users.

    #189

    Detailed answer

    Use aria-current=page on the item representing the current page and supply an obvious visual state too.

    This differs from aria-selected, which belongs to particular widgets. Mark the actual current destination rather than setting the state on every link in a broad topic category.

    Example

    <nav aria-label="Primary"><a href="/html/" aria-current="page">HTML</a><a href="/examples/">Examples</a></nav>

    Understanding the behavior

    Aria-current=page identifies the link representing the current page within a navigation set. It describes location rather than selection in a custom widget. A visual active style can accompany it, but color alone is not an accessible indication.

    Practical implementation notes

    Check that only the appropriate item is current in each navigation group. On a new route, both the active styling and the attribute should update rather than remaining attached to a hard-coded homepage link.

    How to check it

    Inspect aria-current and the visible selected appearance on the matching destination.

    Expected result

    One current destination is clear without misusing widget selection states.

    Watch out: Do not use aria-selected to mark an ordinary current-page navigation link.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.