Test with the Keyboard
Use the Tab key in the live preview to see your focus ring on buttons, links, form fields and custom cards, or show focus on all of them at once.
Design an accessible CSS focus ring, test it with your keyboard, check the WCAG contrast and copy the code. Fast, free and no signup.
Pick a preset or set the thickness, offset and colors.
Press Tab in the preview and read the contrast checks.
Paste the CSS or Tailwind classes into your project.
Looking for a free focus indicator generator? Design a clear, accessible CSS focus ring in seconds. Choose the thickness, offset, color and style of the outline, try a ready-made preset such as a double ring, a glow or a thick block, and see the result on real buttons, links, inputs, checkboxes and cards. Press the Tab key in the live preview to test it the way keyboard users do. The tool checks the contrast of your focus color against the page and the component, reports whether it meets WCAG 1.4.11 and the thickness guidance of WCAG 2.4.13, and then gives you clean :focus-visible CSS, with optional high contrast mode support, or ready-to-use Tailwind classes. A visible focus style is one of the simplest and most important accessibility fixes for any website. There is no signup and nothing to install, and everything runs in your browser.
Use the Tab key in the live preview to see your focus ring on buttons, links, form fields and custom cards, or show focus on all of them at once.
See the contrast ratio of the ring against the background and the component, and get clear pass and warning messages.
Copy production-ready :focus-visible CSS or Tailwind classes, with an optional forced-colors rule for Windows high contrast mode.
A focus indicator, also called a focus ring, focus outline or focus state, is the visual cue that shows which element has keyboard focus. When a person presses the Tab key to move through links, buttons and form fields, the focus indicator shows where they are on the page. It is essential for people who cannot use a mouse, including people with motor disabilities, people who use a keyboard or switch device, and screen reader users who also see the screen, as well as power users who simply prefer the keyboard. Without a visible focus indicator, keyboard navigation turns into guesswork.
The :focus-visible pseudo-class is the modern way to style keyboard focus. It is supported in all current browsers, and it shows the ring when the browser decides that an indicator is useful, which is mainly during keyboard navigation. A basic accessible focus style looks like this:
:focus-visible {
outline: 3px solid #2563eb;
outline-offset: 2px;
}
The outline follows the shape of the element, including rounded corners in modern browsers, and the outline-offset property adds a gap between the element and the ring, which makes the indicator easier to see. Using outline instead of border or width changes also means that the ring does not shift the layout when it appears.
CSS has several focus-related selectors. Knowing the difference helps you pick the right one for each job.
| Selector | When it matches | Use it for |
|---|---|---|
:focus |
Matches whenever an element has focus, including after a mouse click | A fallback for very old browsers |
:focus-visible |
Matches when the browser decides a visible indicator is helpful, mostly keyboard use | The best choice for most focus rings |
:focus-within |
Matches a container when it or any child has focus | Highlighting a form group, card or search box |
:focus:not(:focus-visible) |
Matches focus that came from a mouse or touch | Removing the ring for pointer users, if a design needs it |
Several success criteria in the Web Content Accessibility Guidelines (WCAG) deal with focus. Together they describe a focus indicator that is present, easy to see and not hidden.
| Criterion | Level | What it asks | How this tool helps |
|---|---|---|---|
| 2.4.7 Focus Visible | AA | Every keyboard-operable control must have a visible focus indicator | The live preview shows the ring on real controls |
| 1.4.11 Non-text Contrast | AA | UI components and states need a 3:1 contrast with adjacent colors | The contrast checker tests the ring against the page and the component |
| 2.4.11 Focus Not Obscured (Minimum) | AA (WCAG 2.2) | A focused element must not be completely hidden by other content | Use scroll-padding and check sticky headers (see the guide) |
| 2.4.13 Focus Appearance | AAA (WCAG 2.2) | A strong indicator: at least 2 CSS px thick perimeter and a 3:1 change in contrast | The thickness check follows this guidance |
| 1.4.1 Use of Color | A | Color alone must not be the only way to show information | Prefer an outline or ring over a color change alone |
Many accessibility laws and standards refer to WCAG, including the ADA in the United States, Section 508 and the European standard EN 301 549. This page is general information and not legal advice.
A focus indicator has two neighbors: the page background on the outside and the component on the inside. The ring needs enough contrast against the colors it touches. A color such as medium blue works on a white page but can fade on a dark blue button, and a light ring works on dark backgrounds but disappears on white. The most reliable solution is a two-tone ring: an outer outline in one color and an inner ring in a strongly contrasting color. At least one band always stands out, whatever the background is.
:focus-visible {
outline: 2px solid #1e3a8a;
outline-offset: 2px;
box-shadow: 0 0 0 2px #ffffff;
}
In this example, the 2 pixel box-shadow fills the gap created by the 2 pixel outline offset, which gives a white inner band and a dark blue outer band.
One of the most common accessibility mistakes is to remove the focus outline because the default ring looks ugly or appears when a button is clicked. The better solution is to use :focus-visible, so that the ring shows for keyboard users only, and to design a ring that fits your brand. If you do remove the default outline, always add another clear visible style, such as a thick outline, a ring made with box-shadow or a strong border change. Remember that box-shadow and background changes are removed in some high contrast modes, so keep an outline in the rule.
People who use Windows high contrast or other forced color modes see the page with a limited set of system colors. In this mode, most author colors and shadows are replaced, but outlines are kept. Adding a forced-colors rule helps you make sure the focus ring uses a system color that stands out.
@media (forced-colors: active) {
:focus-visible {
outline: 3px solid CanvasText;
outline-offset: 2px;
}
}
Different components call for slightly different treatments. Use one shared focus style across your site so that it is consistent and easy to recognize, and adjust the offset or color only where needed.
| Component | Recommended focus style | Note |
|---|---|---|
| Links | An outline with a 2 px offset, or a thick underline plus an outline | The default ring is often enough, make sure it has contrast |
| Buttons | A 3 px outline with a 2 px offset. A two-tone ring works on colored buttons | Do not rely on a background color change alone |
| Text inputs and selects | A visible outline or a thicker colored border plus a ring | Keep the border contrast at 3:1 as well |
| Checkboxes and radios | A ring around the custom control, not only the hidden input | Style the visible control when the real input has focus |
| Cards and custom widgets | Use :focus-visible on the container with tabindex="0" and a visible ring | Make sure the whole card shows the focus |
| Dark backgrounds | A light ring, or a two-tone ring with a dark inner band | Test again on every dark theme color |
A good focus ring is useless if the focused element is hidden under a sticky header, a cookie banner or a chat widget. WCAG 2.2 criterion 2.4.11 asks that a focused element is not entirely hidden by other content. You can fix the most common case with scroll-padding, which tells the browser to keep space at the top of the scroll area when it brings a focused element into view.
html {
scroll-padding-top: 80px; /* height of your sticky header */
}
Focus indicators work together with a logical tab order. Keep the order of focusable elements in line with the visual order, avoid positive tabindex values, and add a skip link at the top of the page so that keyboard users can jump past the navigation. Make sure the skip link becomes visible when it receives focus.
<a class="skip-link" href="#main">Skip to main content</a>
...
<main id="main" tabindex="-1">...</main>
| Mistake | Problem | Fix |
|---|---|---|
| outline: none with no replacement | Keyboard users cannot see where they are | Add a visible outline, ring or other clear style |
| A very thin or faint ring | Hard to see, especially for low vision users | Use at least 2 px, ideally 3 px, with 3:1 contrast |
| A ring with the same color as the background | The indicator disappears on some components | Use a two-tone ring or test against every background |
| Only a subtle color change on focus | Fails for color blindness and low contrast | Add an outline or border change |
| Hiding focus for everyone with :focus | Removes the indicator for keyboard users too | Use :focus-visible and keep the ring for keyboard focus |
| Focus ring clipped by overflow: hidden | The ring is cut off at the container edge | Use outline-offset carefully or add padding to the container |
| Focused item hidden under a sticky header | The user cannot see the focused element | Add scroll-padding-top equal to the header height |
| Different styles on every component | Users have to relearn the focus style | Define one consistent focus style in a shared rule |
Tailwind provides the focus-visible variant, so you can write a focus ring directly in your class list, for example focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2. The Tailwind tab of this generator creates classes with arbitrary values for your exact thickness, offset and colors. For a two-tone ring, it adds a box-shadow class as well. If you use Tailwind v4, check the outline utilities in your version, because the base outline class changed.
This CSS focus ring generator is free to use as often as you like, with no signup and no limits. It runs entirely in your browser, so your colors and settings are never sent to our server. Design your focus style, test it with the Tab key, check the contrast and copy the code to make your website easier to use for everyone.
Find answers to common questions about focus rings, :focus-visible, contrast and WCAG.
A focus indicator is the visual outline or highlight that shows which element on a page currently has keyboard focus, such as a link, button or form field. When someone presses the Tab key to move through a page, the focus indicator tells them where they are. Browsers show a default focus ring, and you can replace it with your own CSS style, as long as it stays clearly visible.
Use the :focus-visible pseudo-class and give it a clear outline, for example :focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }. Make the indicator at least 2 pixels thick, give it a color contrast of at least 3:1 against the colors next to it, and never remove the default outline with outline: none unless you provide a better replacement. This generator builds the CSS for you and checks the contrast.
The :focus pseudo-class matches an element whenever it has focus, including after a mouse click. The :focus-visible pseudo-class matches only when the browser decides that a visible indicator is helpful, which is usually when the user navigates with the keyboard. Using :focus-visible lets you show a strong ring for keyboard users without showing it on every mouse click on a button.
WCAG 1.4.11 Non-text Contrast (Level AA) asks for a contrast ratio of at least 3:1 for the visual information that identifies user interface components and their states, which includes focus indicators. The ring should have at least 3:1 contrast against the colors it touches, such as the page background and the component itself. A two-tone ring, with a light and a dark band, is a reliable way to meet this on any background.
Yes, if you remove the outline and do not replace it. Keyboard users then cannot see where they are on the page, which fails WCAG 2.4.7 Focus Visible (Level AA). If you want a different look, replace the outline with your own visible style, for example a thicker outline, a box-shadow ring or a color change. Never leave an interactive element with no visible focus state.
WCAG 2.2 added two focus criteria. 2.4.11 Focus Not Obscured (Minimum), Level AA, requires that a focused element is not completely hidden by other content such as a sticky header or a cookie banner. 2.4.13 Focus Appearance, Level AAA, describes a strong indicator: an area at least as large as a 2 CSS pixel thick perimeter of the element, with a contrast change of at least 3:1 between the focused and unfocused states. Following the AAA guidance is a good target even if you only need AA.
Yes. It is free, needs no signup and runs entirely in your browser. Your colors and settings are not sent to our server. You can press the Tab key in the preview to see your focus style on real elements, check the contrast results, and copy the CSS or the Tailwind classes into your project.
Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.
Explore All Tools →