Accessible CSS focus visible indicators are essential visual cues that inform keyboard users which element currently has focus. When a user navigates through a webpage using the Tab key, the browser applies a default outline to interactive elements like links, buttons, and form fields. Customizing these indicators requires a balance between design aesthetics and strict accessibility standards to ensure that every user can identify their position on the page without difficulty during their browsing session.
Why is focus visibility critical for your website?
Many designers mistakenly remove the default focus outline because they believe it detracts from the visual design of their site. However, removing this outline without providing a visible replacement leaves keyboard users in the dark. Without a clear indicator, users who cannot use a mouse have no way to know where they are navigating. This creates a significant barrier that prevents users from interacting with forms, menus, and call-to-action buttons. WCAG 2.2 Criterion 2.4.13 explicitly requires that focus indicators must have sufficient visual contrast and a clear area to be identified easily. By treating focus states as a core component of your design system, you ensure that your platform remains open to a wider range of users, which is a standard practice for inclusive web design.

What are the rules for WCAG 2.2 Criterion 2.4.13?
The WCAG 2.2 guidelines provide specific requirements for focus appearance to ensure that indicators are not missed by users. The indicator must have a minimum contrast ratio against the background, and it must cover a specific area of the element. These standards prevent designers from using subtle, thin lines that blend into the interface. Instead, the focus indicator should be bold enough to stand out immediately. When you implement these indicators, verify that they do not conflict with the overall page layout or obscure other important content while still providing a clear signal of the active element. A common pattern is to use a thick, high-contrast border or a background color change that triggers upon focus.
How can you implement custom focus styles in CSS?
Implementing custom styles involves using the :focus pseudo-class in your CSS. You can modify the outline property, but you should also consider other visual changes like background color, shadow, or text weight to create a high-visibility effect. When you define these styles, ensure that you do not use only color changes, as color-blind users might struggle to identify the focus state. Instead, combine multiple visual indicators. For example, adding a solid border and a slight background change creates a strong visual cue that is hard to overlook. You can also use the :focus-visible pseudo-class, which is a modern approach that allows you to show the focus indicator only when the user is navigating with a keyboard, keeping the design clean for mouse users.
Best practices for CSS focus implementation
- Always use high-contrast colors that contrast significantly with the background.
- Ensure the focus indicator is at least 2 pixels thick to be easily seen.
- Avoid relying solely on color; incorporate shape or shadow changes.
- Test your focus states by navigating your entire site using only the Tab and Enter keys.
- Use the :focus-visible property to target keyboard-only users specifically.
Comparison of different focus indicator techniques
| Technique | Visual Impact | Accessibility Level |
|---|---|---|
| Default Outline | Minimal | Basic |
| Custom Border | High | Strong |
| Box Shadow | Moderate | Good |
How Alien Road applies focus visibility standards
At Alien Road, we integrate accessibility into our design process from the initial wireframe stage. When building a client site, we define a global focus style in our CSS variables that matches the brand identity while meeting the WCAG 2.2 contrast ratios. We perform a manual audit of all interactive components, such as input fields, navigation menus, and buttons, to ensure the focus state is consistent. In a typical engagement, we document these states in our style guide, providing developers with clear requirements for hover, active, and focus states. This ensures that every element remains consistent, reducing the risk of accessibility gaps as the project grows.

Common mistakes to avoid when styling focus
One frequent error is setting outline: none on all elements to remove the browser default without providing a fallback. This effectively breaks navigation for keyboard users, making the site unusable for anyone relying on assistive technology or keyboard shortcuts. Another mistake is using a focus indicator that is too thin or matches the background color too closely. These indicators fail the contrast requirements defined in WCAG 2.2. Always check your focus states against the background colors of every section of your page, as a color that works on a white header might be invisible on a dark footer. Consistent testing is the only way to avoid these pitfalls and maintain a high standard of digital quality.
How to start improving your focus indicators this week
Start by auditing your most important interactive pages, such as your contact form or checkout page. Navigate through these pages using only the keyboard to identify where the focus indicator is missing or weak. Once you identify these gaps, update your CSS stylesheet to apply a consistent focus style across your site. Use the list below to guide your weekly optimization efforts and ensure you are not missing any critical components. By dedicating time to these small adjustments, you create a more professional and inclusive experience for every visitor who lands on your site.
- Audit existing forms and buttons for missing focus states.
- Define a high-contrast focus color in your site-wide CSS variables.
- Apply :focus-visible to all interactive elements to clean up mouse-based interactions.
- Check all focus indicators against WCAG 2.2 contrast standards.
- Run a keyboard navigation test on all primary user flows.
Frequently Asked Questions
Can I remove the default focus outline?
You can remove the default outline only if you replace it with a clear, custom focus indicator. Removing it without a replacement makes the site inaccessible to keyboard users. Ensure your replacement meets contrast requirements and provides a visible change that makes the active element easy to identify.
What is the difference between :focus and :focus-visible?
The :focus pseudo-class applies the style whenever an element is focused, regardless of the input method. The :focus-visible pseudo-class is smarter; it allows the browser to show the focus indicator only when the user is using a keyboard, preventing unnecessary outlines for mouse users.
How thick should a focus indicator be?
While there is no single mandated pixel value, a thickness of at least 2 pixels is generally recommended for visibility. The key is that it must be easily identifiable against the background. Always verify that the indicator is thick enough to pass accessibility checks.
Should I use box-shadow for focus states?
Box-shadow is a popular way to create a focus indicator that does not change the layout of the page. It is highly flexible and can be styled to be very visible. Just ensure the shadow has enough contrast and does not blend into the background or surrounding elements.
How do I test my site for focus visibility?
The simplest way to test is to put your mouse away and navigate your entire site using only the Tab, Shift+Tab, and Enter keys. If you ever lose track of where you are on the page, the focus indicator is not working correctly and needs to be updated.
Keep reading: Web Design and Development · Web Design