Links and interactive elements

Buttons #

Having accessible buttons is crucial for a website because they enable all users to navigate and interact with content effectively. The following key principles guide the creation of accessible buttons that enhance usability for individuals relying on screen readers:

  • Every button receives a clear and visible focus indicator when navigated to using the keyboard (e.g., using the “Tab” key).
  • Buttons are reachable in a logical, sequential order, following the page content’s natural flow.
  • Pressing the “Enter” or “Space” key while a button is focused triggers the button’s action.
  • Buttons consistently behave as interactive elements and respond correctly to keyboard interactions across all browsers.
  • Each button has a clear and descriptive label that accurately describes its purpose when announced by the screen reader.
  • Buttons are identified as “button” elements by the screen reader, not as links or other non-interactive elements.
  • When a button has a dynamic state (e.g., “expanded,” “collapsed,” “pressed”), the current state is conveyed to the screen reader.
  • Buttons do not repeat unnecessary information that could overwhelm the user.
  • After activating a button, screen reader users receive confirmation or feedback (e.g., focus shift or announcement of a successful action).
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Accessible Button Example</title>
    <style>
        /* Styles for visible focus indicator */
       .btn{padding:10px 20px;font-size:16px;background-color:#007bff;color:#fff;border:none;cursor:pointer;outline:0}
       .btn:focus{outline:#FFBF00 solid 3px}
    </style>
    <script>
        function buttonAction() {
            // Example feedback to screen readers
            const liveRegion = document.getElementById('status');
            liveRegion.textContent = 'Action successful. You have activated the button.';
        }
    </script>
</head>
<body>
    <h1>Accessible Button Example</h1>
    <!-- Button with proper role and ARIA attributes -->
    <button class="btn" type="button" aria-pressed="false" aria-label="Submit Form" onclick="buttonAction()">
        Submit
    </button>
    <!-- Live region for screen reader feedback -->
    <div id="status" aria-live="polite" role="status" style="margin-top: 20px;"></div>
</body>
</html>

Screen reader: NVDA

Video:

Accessible links are essential for ensuring that all users have equal access to information and functionality on a website.

Accessible links include key features such as:

  • Links receive a clear and visible focus indicator when navigated to using the keyboard (e.g., using the “Tab” key).
  • Links are reachable in a logical order, following the natural reading flow of the page content.
  • Pressing the “Enter” or “Space” key while a link is focused triggers navigation to the linked page or action.
  • Links consistently behave as navigational elements and respond correctly to keyboard interactions.
  • Each link has a clear and descriptive label that provides meaningful information, so users know where the link leads.
  • Links are correctly identified as “link” elements by the screen reader, not as buttons or other non-navigational elements.
  • Avoid using phrases like “Click here” or “Read more” without context. Links should make sense when read out of context, describing their destination or action clearly.
  • When multiple links on a page have the same text (e.g., multiple “Learn more” links), they include additional contextual information (e.g., `aria-label` or visually hidden text) to differentiate their purpose for screen reader users.
  • When the link leads to an already visited page or currently active page, that information is conveyed to the screen reader.
  • When a link opens a new tab in the browser upon being clicked, its descriptive label clearly indicates this action, using phrases such as “opens in a new tab” or an appropriate icon. This ensures that users are aware of the change in context and can prepare for the navigation.
  • Avoid having multiple links that lead to the same destination or perform the same action without clear purpose. Repetitive links confuse screen reader users, as they will hear the same destination announced multiple times.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Accessible Links Example</title>
    <style>
        /* Styles for focus indicator */
      a{color:#007bff;text-decoration:none;outline:0}
      a:focus{outline:#FFBF00 solid 3px}
    </style>
</head>
<body>
    <h1>Accessible Links Example</h1>
    <p>
        Visit the <a href="https://example.com" aria-label="Example homepage">Example Homepage</a> to learn more about our services.
    </p>
    <p>
        Read our <a href="https://example.com/blog" aria-label="Our latest blog post on accessibility best practices">latest blog post on accessibility best practices</a> for detailed guidelines.
    </p>
    <p>
        Want to know more? <a href="https://example.com/learn-more" aria-label="Learn more about our offerings">Learn more about our offerings</a>.
    </p>
    <p>
        <a href="https://example.com/contact" aria-label="Contact us, opens in a new tab" target="_blank">Contact us</a> <span aria-hidden="true">(opens in a new tab)</span>.
    </p>
    <p>
        <a href="#section1" aria-label="Jump to section 1 for more details">Jump to Section 1</a> to continue reading.
    </p>
    <h2 id="section1">Section 1: More Details</h2>
    <p>This section contains more detailed information.</p>
</body>
</html>

Screen reader: NVDA

Video:

What are your feelings

Updated on March 5, 2025