Visual Focus

Explanation

Visual Focus is a cue to indicate for the user which part of the application is currently active. It can be a the window, and it can be a button.

Can you identify which of the items in the screenshot is focused? how?

Visible focus is an essential aspect of web accessibility that ensures users with visual impairments or motor disabilities can navigate and interact with web content easily. When a user interacts with a web page using the keyboard or a screen reader, the focus is applied to elements such as links, form fields, buttons, etc. This focus is represented by a visual indication, usually a focus ring or outline, around the active element.

By default, most browsers have a built-in focus indicator that outlines the focused element, but the appearance of this focus indicator can vary depending on the browser and operating system, and sometimes it may be difficult to see or even hidden due to custom CSS styles.

To improve accessibility and make the focus indicator clearly visible, it's essential to customize the focus styles using CSS. Here are some best practices to ensure a visible focus:

Use CSS to Style Focus

You can modify the appearance of the focus indicator to make it more prominent and noticeable. Some common approaches include changing the color, thickness, or style of the focus ring. For example:
/* Example of a blue focus ring with thicker outline */
:focus {
    outline: 2px solid blue;
}            

Avoid Removing Focus Outlines

It's crucial not to remove the focus indicator entirely, as it helps users understand where they are on the page and how they are interacting with the content. Some websites, in an attempt to improve aesthetics, remove focus outlines, but this creates accessibility issues.

Ensure Sufficient Contrast

Make sure that the focus indicator color has enough contrast against the background color to be clearly visible for all users, including those with low vision.

Focus States for Different Elements

Customize the focus indicator for various interactive elements like links, buttons, form fields, etc., so users can easily identify the type of element they are interacting with.

/* Example of a red focus ring for links */
a:focus {
    outline: 2px solid red;
}
/* Example of a green focus ring for buttons */
button:focus {
    outline: 2px solid green;
}

Test with Keyboard Navigation

Check the visibility and appearance of the focus indicator using keyboard navigation. You can use the "Tab" key to move through interactive elements on your website and observe the focus styles.

Wrapping up

Remember that visible focus is not only beneficial for users with disabilities but also for all users, as it provides a clear indication of the current active element. By following these best practices, you can improve the accessibility of your HTML content and create a more inclusive web experience for everyone.

Exercise

We were tasked to provide a contact form. The previous developer, whose name will not be mentioned wrote the following code.

Designer

Write instructions for the deverloper to fix the accessibility of the following form.Provide visual reference (mock screenshot or video).

Developer
Tester

Contact form

Contact hours: