Accessibility・Making things clear to see

A page you can use with the keyboard alone

Some people don't use a mouse and move through a page with the Tab key. We keep the focus ring that shows them "where am I now?" — and instead of removing it, we make it look sharp.

People who can’t use a mouse, or who find the keyboard faster, move through links and buttons one by one with the Tab key. What tells them “where am I right now” is the focus ring that outlines the element.

Let’s try it out

First, let’s experience moving around with the Tab key.

The orange ring tells you “you are here.” Press Enter or Space to activate that spot.

What not to do: outline: none

The focus ring is really the CSS outline. Because the default look feels a bit clunky, some sites remove it like this.

button:focus {
  outline: none;   /* ❌ Never do this */
}

It looks tidy, but keyboard users lose their cursor. The right move isn’t to “remove” it, but to “redraw it nicely,” like below.

TipsWhich reset CSS should I use?Not sure what reset CSS is? Start here

The right way: redraw with focus-visible

button:focus-visible {
  outline: 3px solid #e5967a;
  outline-offset: 2px;
}
PartMeaning
:focus-visibleA selector that shows the ring only during keyboard use
outline: 3px solid …The ring’s thickness, style, and color (your brand color is OK)
outline-offset: 2pxLeaves a gap between the element and the ring for readability

Using :focus-visible instead of :focus is the standard today. No ring appears when you click with the mouse, and it shows up only when you arrive by Tab — so mouse users and keyboard users both get a good experience.

In the first place, Tab only reaches “pressable tags”

The Tab key only stops on inherently pressable tags like <a>, <button>, and <input>. Even if you make a <div> or <span> act like a button by adding click behavior (with JavaScript), Tab skips right past it — for keyboard users, it’s as if it doesn’t exist.

<div onclick="send()">Send</div>       <!-- ❌ Tab can't reach it -->
<button onclick="send()">Send</button> <!-- ○ Tab stops here, and Enter presses it -->
When you press Tab, the ring only stops on the button. The div may look pressable, but the keyboard skips right past it.

Make pressable things out of pressable tags. “Writing HTML that matches meaning,” which you learned in the HTML course, is also the foundation for keyboard operation.

HTMLButtons and input fieldsThe basics of the button tag are in this lesson

Tab order is the HTML order

Focus moves in the order you wrote it in the HTML. If the visual arrangement and the written order don’t match, the ring jumps around the screen and causes confusion. Move the layout around with CSS, but write the HTML in reading order, in the order people operate it — keep this principle and it naturally comes out right.

Summary of this lesson

  1. The focus ring is the keyboard user’s cursor. Don’t remove it with outline: none
  2. Instead of removing it, redraw it nicely with :focus-visible + outline
  3. Tab order = HTML order. Writing in reading order is the foundation

FAQ

What's the difference between :focus and :focus-visible?
:focus shows a ring for both mouse clicks and the keyboard, but :focus-visible shows a ring only during keyboard use. :focus-visible solves the problem where the ring on a click bothered people and made them want to remove it.
How are outline and border different?
outline is drawn outside the element and doesn't affect layout. A border is part of the element, so making it thicker shifts the things around it. For a focus ring, outline is the better fit because adding or removing it doesn't move the layout.
What color should the focus ring be?
As long as it stands out clearly from the background, your site's brand color is fine. Make it 2 to 3px thick, and leave a little gap with outline-offset so it's easier to spot.