CSS Hover Tooltips with popover=hint and interestfor
Hover tooltips without JavaScript events
Tooltips required JavaScript mouseenter/mouseleave listeners, focus handling and manual positioning. In Chrome and Edge, popover=hint with the interestfor attribute now gives you declarative, accessible hover UI. Firefox and Safari don't support interestfor yet, so keep a small JavaScript fallback that calls showPopover() and hidePopover().
The old hack vs the modern fix
View demo/* JS: manage hover, focus, and position */
btn.addEventListener('mouseenter', () => {
tip.hidden = false;
positionTooltip(btn, tip);
}
);
btn.addEventListener('mouseleave', () => {
tip.hidden = true;
}
);
btn.addEventListener('focus', /* … */
);
btn.addEventListener('blur', /* … */
);<button interestfor="tip">
Hover me
</button>
<div id="tip" popover=hint>
Tooltip text
</div>Popover hint browser support
Live demo
Why the modern way wins
All input modes
In Chrome and Edge, the browser triggers on hover (mouse), focus (keyboard) and long-press (touch) with no event handling. Firefox and Safari still need a JavaScript fallback.
Non-destructive
Hint popovers don't close other open auto or manual popovers. Layered UI coexists naturally.
Built-in delay
The interest-delay property (default 0.5s) prevents accidental triggers. Configurable with CSS.
- Lines Saved
- 14 → 5
- No event listeners
- Old Approach
- JS event listeners
- mouseenter, mouseleave, focus, blur
- Modern Approach
- popover=hint
- interestfor + popover=hint
How it works
Building accessible tooltips required at least four event listeners (mouseenter, mouseleave, focus, blur), a delay mechanism to prevent flicker, position logic and careful DOM management. Libraries like Tippy.js exist specifically because this is so tedious to get right.
The new popover=hint type paired with the interestfor attribute handles all of this declaratively. The interestfor attribute on the trigger element points to the tooltip's ID. The browser shows the popover when the user 'shows interest' (hover, focus, long-press) and hides it when interest ends. Customize the delay with the interest-delay CSS property. Unlike popover=auto, hint popovers coexist with other open popovers. This works in Chrome and Edge today. Firefox and Safari don't support interestfor yet, so keep a few lines of JavaScript that call showPopover() and hidePopover() as a fallback.