brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: :focus-visible in css shows focus rings for keyboard users only

Css
~/tips/tip-css-focus-visible-keyboard-ring

button:focus-visible, a:focus-visible {

Shows the focus ring when the keyboard is used and skips it for ordinary mouse clicks.

Removing the outline on buttons fixes the look and breaks keyboard navigation.

button:focus-visible, a:focus-visible {
  outline: 3px solid #0b6bcb;
  outline-offset: 2px;
}

:focus-visible matches when the browser thinks a focus indicator is useful: always for keyboard navigation, usually not after a mouse click on a button. That gives you a clear ring where it is needed without the ring flashing on every click. Never write outline: none without a replacement. Text fields still show the ring on a click, because typing needs to be obvious there. The selector is supported in every current browser.

Further reading: MDN: :focus-visible

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link