Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 3670

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 26, 20242024-11-26T04:52:06+00:00 2024-11-26T04:52:06+00:00

Focusing on focus indicators

  • 61k

Websites contain many interactive elements such as buttons, links and various types of inputs. While these elements are often activated by mouse or touch, there's a substantial minority of people that use keyboards or other input devices for navigation.

Navigating with Keyboards

Keyboard users navigate through websites using the tab key, moving from one interactive element to another in order. Focus indicators play a crucial role in this process, visually highlighting the element currently under keyboard control. Without them, it becomes a lot more difficult to know which interactive element will be activated when pressing the Enter or Space key.

Browser Defaults and Accessibility

Focus indicators are built into the browser by default and if left untouched, they automatically count as accessible even if browser defaults don't always meet all WCAG (Web Content Accessibility Guidelines) criteria such as color contrast.

At the time of writing this (Jan 2024), Chrome-based browsers on Windows provide a double-layered focus indicator with a black outline on the inside and a white outline on the outside. This means it's more likely to work with both light and dark backgrounds.

focus indicator in Chrome showing a black outline around a button

Focus indicator in Chrome with a black background showing a white outline around a button

Firefox on Windows goes for a double-layered dark blue/light blue outline combination around buttons and a single blue ring around links.

Focus indicator in Firefox showing a dark blue and light blue outline around a button

So if they're already built into the browser, what's the problem?

Well, many people don't like the look of the default focus indicator, especially as they are not consistent across different browsers, and therefore use CSS to turn it off completely. Unfortunately, this leads to a much poorer user experience. So let's dive into how we can make a more accessible focus indicator.

Accessible Focus Indicators

Color Contrast

A focus indicator needs to have at a contrast of at least 3:1 for all adjacent (touching) colors. That means if the focus indicator surrounds a button it must contrast against the button background color and the background behind the button.

If you have sections of your site with different background colors or interactive elements that have different colors and one focus indicator doesn't work for all elements, it is possible to use CSS to style the focus indicator colors differently for different elements.

If you include different website themes, such as dark mode and light mode, you will also need to consider the color contrast for all themes.

Spacing around interactive elements

If you use an outline or a border as a focus indicator, leaving a small amount of space around an interactive element can also make it easier to spot which element has focus. This also means you only need to consider the focus indicator color constrast against the background color since the color of the interactive element is not directly touching the outline.

Double outlines

Double-layered outlines in two contrasting colors can be a good way to make focus indicators more flexible, especially if you're dealing with dark and light mode. This way, the dark part of the focus indicator will show on light backgrounds and the light part will show on dark backgrounds.

High contrast mode

Windows high contrast mode overrides most default colors with a minimal palette of highly contrasting colors. However, problems can arise if you've restyled your focus indicator and used

outline:none somewhere within your CSS. This means the focus indicator in high constrast mode will no longer be visible. Instead, use an outline set to transparent. This will not show up normally if you've restyled the focus indicator but will become visible in high contrast mode.

Another way to make sure focus indicators are visible even in high contrast mode is to use the forced-colors media query to apply specific styling. However, be careful to override forced colors sparingly, as the mode is styled the way it is for a reason.

Conclusion

Creating a more accessible focus indicator involves thoughtful consideration of color contrast, spacing, and adaptability to various modes. By understanding and addressing these factors, designers and web developers can contribute to a more inclusive online experience for all users, regardless of their chosen input device or accessibility needs.

Resources

  • Quick Tips for High Contrast Mode
  • MDN forced-colors

a11ywebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.