caret‑color CSS Demo - Online Colorful Text Cursors
Change the text input cursor color. See the effect live. Copy the minimal CSS. Simple but delightful.
UD5 Toolkit
Test and compare :focus-visible vs :focus pseudo-classes in real time. Discover how browsers intelligently show focus rings only when you need them — for keyboard navigation, not mouse clicks.
tabindex="0"
tabindex="0"
—
<input>, <textarea>, <select>), most browsers also match :focus-visible on mouse click — because showing a focus indicator on text fields is always helpful for usability. Buttons and links typically only match :focus-visible via keyboard navigation.
/* ✅ Best Practice: Hide default focus, show only for keyboard */
:focus {
outline: none;
}
:focus-visible {
outline: 3px solid #3b82f6;
outline-offset: 2px;
box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
border-radius: 4px;
}
/* For older browsers, use the polyfill: */
/* npm install focus-visible */
/* import 'focus-visible'; */
:focus-visible is a CSS pseudo-class that applies styles only when the browser determines that a focus indicator should be visible. It represents the browser's best guess about when the user really needs to see a focus ring — typically when navigating via keyboard (Tab, arrow keys) rather than mouse click or touch.
Introduced by the CSS Selectors Level 4 specification, it helps solve a long-standing UX problem: focus rings are essential for keyboard users but visually annoying for mouse users.
:focus — matches any element receiving focus, regardless of input modality (mouse, keyboard, touch, or programmatic). The focus ring appears every single time.
:focus-visible — matches only when the browser believes the user needs to see the focus indicator. Typically:
Native support is excellent across all modern browsers:
| Browser | Version | Support |
|---|---|---|
| Chrome | 86+ | ✅ Full |
| Firefox | 85+ | ✅ Full |
| Safari | 15.4+ | ✅ Full |
| Edge | 86+ | ✅ Full |
| Samsung Internet | 16+ | ✅ Full |
| iOS Safari | 15.4+ | ⚠️ Partial |
For older browser support, use the official focus-visible polyfill from WICG.
The polyfill adds a .focus-visible class to focused elements when the browser would have matched :focus-visible. Here's how to use it:
npm install focus-visible
// In your JS entry file:
import 'focus-visible';
/* In your CSS, use both to cover all browsers: */
:focus { outline: none; }
:focus-visible,
.focus-visible {
outline: 3px solid #3b82f6;
outline-offset: 2px;
}
The polyfill is lightweight (~2KB) and works by simulating the browser's heuristic using JavaScript event listeners for keyboard and mouse input.
This is expected browser behavior and part of the specification's heuristic. Browsers determine when to match :focus-visible based on element type and context:
You cannot override this heuristic with CSS alone. If you truly need to suppress focus indicators on text inputs for mouse users, you'd need JavaScript-based solutions (though this is generally not recommended for accessibility reasons).
The recommended best practice combines both pseudo-classes for maximum compatibility and usability:
:focus { outline: none; }:focus-visibleoutline-offset to prevent the focus ring from touching the element edge.focus-visible class with the polyfill for older browsers❌ Avoid: :focus { outline: none; } without providing an alternative — this breaks keyboard accessibility entirely.
Absolutely! You're not limited to the browser's default outline. Here are some creative approaches:
/* Glowing ring */
:focus-visible {
outline: none;
box-shadow: 0 0 0 3px #fff, 0 0 0 6px #3b82f6;
border-radius: 6px;
}
/* Underline indicator */
:focus-visible {
outline: none;
border-bottom: 3px solid #3b82f6;
padding-bottom: 2px;
}
/* Inset ring */
:focus-visible {
outline: none;
box-shadow: inset 0 0 0 3px #3b82f6;
}
Just ensure the indicator is clearly visible and meets contrast requirements. The demo on this page uses a blue box-shadow ring for :focus-visible and a red one for :focus to clearly differentiate them.
:focus-visible is a crucial tool for accessibility because it:
Never use :focus { outline: none; } alone without providing a :focus-visible alternative — this creates an accessibility barrier for keyboard-only users.
Change the text input cursor color. See the effect live. Copy the minimal CSS. Simple but delightful.
Measure your visual and auditory reaction speed. Average and best times shown. No data collected. Pure Javascript timing.
Hear a word spoken by browser TTS and type the spelling. Choose difficulty or paste your own list. Great for kids. Local only.
Turn your browser screen into a full‑color flashlight or strobe. Adjust brightness and color. Simple utility.
Hear text spoken word by word with boundary events. See the exact index and character. Advanced TTS dev tool.
Paste your speech, set time limit, and practice with a pacing indicator (words per minute). Refine delivery.
Estimate ovulation day and fertility window from last menstrual period. Displays probable conception dates. Informational only; processes locally in browser.
Paste HTML and see a before/after comparison of minified output. Check the byte savings. All local.
See a comprehensive table of which modern web APIs your current browser supports. Includes WebGPU, AVIF, and more.
Test your browser's built‑in speech recognition. Speak and see the transcribed text appear live. Must‑have for voice app devs.
Convert pixel values to em and rem units based on a base font size. Bidirectional. Must‑have for front‑end developers.
Learn to aim a signal mirror by aligning a virtual finger and target. Simulates the retro‑reflective mesh technique. Practice before you need it.
Paste text and set display speed for Rapid Serial Visual Presentation. Train your reading speed.
Click any element on a demo page and see which events are attached. Visual debugger for event handling.
Paste your script and get an approximate speech duration based on slow/average/fast pace. Avoid overtime.
Use your microphone to dictate text and see it appear live. Also upload an audio file for transcription (limited). All local.
Use your microphone to dictate text and see it appear live. Also upload an audio file for basic transcription. All local.
Simple phase cancellation tool: load a stereo track and attempt to remove center‑panned vocals. Not perfect, but fun to experiment.
Track days of sobriety with a motivational counter and milestone celebrations. Set quit date and see time elapsed in days, hours, minutes. Private & local.
Tap a glass icon each time you drink a cup of water. See your daily intake. Reminders optional. Local storage.
Set a list of agenda items with allocated minutes. Advance through speakers and see remaining time visually. Keep meetings on track.
Request a USB device and communicate with it using the Web USB API. See vendor and product IDs. Experimental.
Start a 10‑15 minute guided laser chase session that ends with the dot landing on a treat, preventing frustration from never catching the prey.
Generate a realistic, random user‑agent string for desktop, mobile, or bot. Perfect for API testing and scraping.
Answer questions and see typical milestones for 0-5 years. Educational reference for parents. Not a diagnostic tool.
Paste robots.txt content and parse it to check validity, find disallowed paths. Educational SEO tool. Local processing.
Generate CUIDs that are optimized for horizontal scaling and collision resistance. Great for client‑side IDs. Pure JavaScript.
Record audio directly from your microphone and download it as a WAV file. Perfect for quick notes. No upload, fully offline support.
Get a short, thought‑provoking insight or proverb. A moment of reflection. Works offline.
Simple tracker to record potty attempts, successes, accidents. See patterns. Data stays local. Aids in toilet training journey.