Living Standard — Last Updated 24 November 2026
interestfor attributeThe interestfor attribute allows authors to set up a
relationship between the triggering element and a separate
target element such as a popover. With this arrangement,
when the user shows interest in the
triggering element (e.g., by hovering or focusing it), the
target element will have an interest event fired on it. If the target is a popover with a
popover visibility state of , this
will show the popover. When the user loses interest (e.g., by
no longer hovering or focusing the interest source or
target) a loseinterest event is fired. If the target is a popover with a
popover visibility state of showing, it
will be hidden.
If specified, the interestfor attribute value must be
the ID of an element in the same tree as the
element with the interestfor attribute.
interface mixin InterestInvokerElement {
[CEReactions, Reflect="interestfor"] attribute Element? interestForElement;
};
The following demonstrates how one might show a tooltip for a button using the
interestfor attribute to associate the button with
a popover representing the tooltip.
<button interestfor=tooltip>
Hover or focus me to show the tooltip
</button>
<div popover=hint id=tooltip>
I will appear when the user shows interest in the button
</div>
Every HTML element has an element-or-null active interest target, initially null.
Every Document has an active interest sources set, a set of
HTML elements, initially the empty set.
The active interest sources set holds all of the HTML elements in the document that have a non-null active interest target, in the order that interest was gained.
Every HTML element has a pending gain interest handle and a pending lose interest handle, which are both a unique internal value or null, initially null.
These handles are used to abort steps that run after a timeout, effectively canceling the tasks.
Every HTML element has a boolean suppress next focus interest, initially false.
Every HTML element has a boolean explicit interest, initially false.
An element has explicit interest when interest was gained through an explicit user action, such as a long press on a touch device. Such interest is not lost when the element stops being hovered or focused, since the element was not hovered or focused to gain interest in the first place.
Every element has an element-or-null active interest source, initially null.
When non-null, an element's active interest target is a cached result
of get the interestfor-associated element and the target's active interest
source points back to the source. This is a convenience that makes it easier to handle
tree modifications that break the association between source and target.
InterestEvent interface[Exposed=Window]
interface InterestEvent : Event {
constructor(DOMString type, optional InterestEventInit eventInitDict = {});
readonly attribute Element? source;
};
dictionary InterestEventInit : EventInit {
Element? source = null;
};
event.sourceReturns the element that triggered interest.
The source getter steps are to return the result of
retargeting source against this's currentTarget.
To handle interest change for an element element, a boolean show, and a boolean viaFocus:
If element is not connected, or element's node document is not fully active, then return.
For each element candidate of element's inclusive ancestors in the flat tree:
If show is true:
For each element upstream of candidate's recursive active interest sources:
Set upstream's pending lose interest handle to null.
This effectively cancels any pending task to lose interest for upstream. User interactions such as hovering or focusing an interest target or its descendants prevent those tasks from running, so that interest isn't lost while the user is interacting with the target.
If candidate is an HTML element:
Set candidate's pending lose interest handle to null.
Let suppressFocusInterest be true if viaFocus is true and candidate's suppress next focus interest is true; otherwise false.
Set candidate's suppress next focus interest to false.
If suppressFocusInterest is true, then continue.
If candidate's active interest target is not null or candidate's pending gain interest handle is not null, then continue.
If candidate is not an a or area element with an
href attribute, nor a button element
that is not actually disabled, then
continue.
Let target be the result of running candidate's get the interestfor-associated element.
If target is null, then continue.
If the computed value of 'interest-delay-start' on candidate is 'normal', then let delay be an implementation-defined number of milliseconds. Otherwise, let delay be the computed value of 'interest-delay-start' on candidate, interpreted as a number of milliseconds.
A typical value for the 'normal' delay is 250 milliseconds.
If delay is negative, infinite, or NaN, then continue.
Let uniqueHandle be null.
Let task be a task that runs the following substeps:
Assert: uniqueHandle is a unique internal value, not null.
If uniqueHandle is not candidate's pending gain interest handle, then abort these steps.
Set candidate's pending gain interest handle to null.
If the interest ready check for candidate and target returns false, then abort these steps.
Gain interest in candidate given target.
Let global be candidate's relevant global object.
Let completionStep be an algorithm step which queues a global task on the timer task source given global to run task.
Set uniqueHandle to the result of running steps after a timeout given global, "interest change", delay, and
completionStep.
Set candidate's pending gain interest handle to uniqueHandle.
Otherwise:
If viaFocus is false and candidate has a flat tree inclusive descendant that the user designates, then continue.
If candidate is an HTML element:
Set candidate's pending gain interest handle to null.
If candidate's active interest target is not null and candidate's explicit interest is false, then schedule losing interest for candidate.
For each element upstream of candidate's recursive active interest sources:
Schedule losing interest for upstream.
To schedule losing interest for an HTML element source:
Let target be source's active interest target.
If target is null, then return.
If the computed value of 'interest-delay-end' on source is 'normal', then let delay be an implementation-defined number of milliseconds. Otherwise, let delay be the computed value of 'interest-delay-end' on source, interpreted as a number of milliseconds.
A typical value for the 'normal' delay is 150 milliseconds.
If delay is negative, infinite, or NaN, then return.
Set source's pending lose interest handle to null.
Let uniqueHandle be null.
Let task be a task that runs the following substeps:
Assert: uniqueHandle is a unique internal value, not null.
If uniqueHandle is not source's pending lose interest handle, then abort these steps.
Set source's pending lose interest handle to null.
If the interest ready check for source and target returns false, then abort these steps.
Lose interest in source given target.
Let global be source's relevant global object.
Let completionStep be an algorithm step which queues a global task on the timer task source given global to run task.
Set uniqueHandle to the result of running steps after a timeout given global, "interest change", delay, and
completionStep.
Set source's pending lose interest handle to uniqueHandle.
To find the recursive active interest sources given an element element, perform the following steps. They return a list of zero or more elements.
Let sources be an empty list.
Let pending be an empty queue.
Enqueue element in pending.
While pending is not empty:
Let current be the result of dequeuing from pending.
While current is not null:
Let source be current's active interest source.
If source is not null, source is not element, and sources does not contain source:
Set current to current's parent node within the flat tree, if that parent node is an element; otherwise, set current to null.
Return sources.
The recursive active interest sources algorithm finds all elements whose active interest target contains (inclusively) a given element, as well as any elements that indirect interest sources through the same condition applied recursively. In effect, all "upstream" interest sources in a graph of active interest target relations are found. Because cycles are possible, it is defined iteratively to avoid infinite loops.
The interest ready check for an HTML element source and an element target returns true if all of the following are true, and false otherwise:
source is an a or area element with an href attribute, or a button element that is not
actually disabled.
source is connected.
source's node document is fully active.
The result of running source's get the interestfor-associated element is
target.
To gain interest in an HTML element source given an element target and an optional boolean explicit (default false):
Assert: the result of running source's get the interestfor-associated
element is target.
If source's active interest target is not null:
If source's active interest target is target:
Set source's pending lose interest handle to null.
If explicit is true, then set source's explicit interest to true.
Return.
Interest has already been gained for the correct target and there is nothing to do except to cancel pending tasks, and possibly upgrade to explicit interest.
If the result of losing interest in source given source's active interest target is false, then return.
This fires the loseinterest
event.
If the interest ready check for source and target returns false, then return.
Assert: source's active interest target is null.
If target's active interest source is not null:
If the result of losing interest in target's active interest source given target is false, then return.
This fires the loseinterest
event.
If the interest ready check for source and target returns false, then return.
Assert: target's active interest source is null.
Let continue be the result of firing an
event named interest at target, using
InterestEvent, with the cancelable
attribute initialized to true, the composed attribute
initialized to true, and the source attribute
initialized to source.
If continue is false, then return.
If the interest ready check for source and target returns false, then return.
Set source's active interest target to target.
Set source's explicit interest to explicit.
Append source to source's node document's active interest sources set.
Set target's active interest source to source.
If target is an HTML element and target's popover visibility state is :
Run show popover given target, false, and source.
If target's popover visibility state is showing, then set target's popover shown via interest to true.
To lose interest in an HTML element source given an element target, an optional boolean cancelable (default true), and an optional boolean hidePopover (default true):
Assert: source's active interest target is target.
Assert: target's active interest source is source.
Let continue be the result of firing an
event named loseinterest at target,
using InterestEvent, with the cancelable
attribute initialized to cancelable, the composed attribute initialized to true, and the source attribute initialized to
source.
If continue is false, then return false.
If source's active interest target is not target, then return true.
Reset interest state for source.
If all of the following are true:
hidePopover is true;
target is an HTML element;
target's popover visibility state is showing; and
target's popover shown via interest is true,
then run the hide popover algorithm given target, true, true, false, and source.
Return true.
To reset interest state for an HTML element source:
Let target be source's active interest target.
Set source's active interest target to null.
Set source's explicit interest to false.
Remove source from source's node document's active interest sources set.
If target is not null, then set target's active interest source to null.
Set source's pending gain interest handle to null.
Set source's pending lose interest handle to null.
When the user designates an element element with a pointing device, other than through touch input, the user agent must queue a task on the user interaction task source to handle interest change for element, true, and false.
When the user no longer designates an element element with a pointing device, other than through touch input, the user agent must queue a task on the user interaction task source to handle interest change for element, false, and false.
The tasks queued on the user interaction task source above must be queued after
any tasks that fire events such as mouseover and mouseout, or that affect the :hover pseudo-class.
Canceling events such as mouseover and mouseout does not prevent the above tasks from running.
When the user long presses an element element on a touch device, the user agent must queue a task on the user interaction task source to run the following steps:
Fire any relevant events, per UI Events or other relevant specifications. [UIEVENTS]
Let event be the Event object for any contextmenu event fired, or null if no such event was
fired.
Let showContextMenu be true if event is not null and its canceled flag is not set.
Let invoker be the closest inclusive
ancestor of element in the flat tree that is an
a, area, or button element, and for which the result of
running its get the interestfor-associated element is not null.
If invoker is null, then abort these steps.
Let target be the result of running invoker's get the interestfor-associated
element.
If target is null, then abort these steps.
Let gainInterestIfReady be the following step:
If the interest ready check for invoker and target returns true, then gain interest in invoker given target and true.
If showContextMenu is true and invoker is not a button
element, then provide an option in the context menu that, when selected, queues a task on the user interaction task source to run
gainInterestIfReady.
For button elements, interest is gained immediately, rather than
through a context menu option.
Otherwise, run gainInterestIfReady.
There is no delay before gaining interest as the long press gesture already has an inherent delay.
When the user clicks, taps, or long presses an element element's '::interest-button' pseudo-element using a pointing or touch device, the user agent must queue a task on the user interaction task source to run the following steps:
Fire any relevant events, per UI Events or other relevant specifications, at element, without running element's activation behavior. [UIEVENTS]
Let event be the Event object for any click event fired, or null if no such event was fired.
If event is not null and its canceled flag is set, then abort these steps.
Let target be the result of running element's get the interestfor-associated
element.
If target is null, then abort these steps.
If the interest ready check for element and target returns true, then gain interest in element given target and true.
There is no delay before gaining interest, and the interest gained is explicit interest. The '::interest-button' pseudo-element is not focusable, so it cannot be used with a keyboard. Keyboard and assistive technology users can instead show interest through the element itself, e.g., by focusing it.
Keyboard interactions are handled in the focus update steps.
For input modalities other than pointing devices, touch, and keyboards, the user agent should provide the ability for the user to show interest.
Authors should not include content in an interest target that requires
significant scrolling (such as maps or large tables), as users might accidentally move the
pointer outside the target while scrolling and unintentionally lose
interest. Authors also should not move focus in response to interest or loseinterest
events (or via the autofocus attribute on an
interest target), because focus changes can themselves trigger interest changes and
cause focus traps or unexpected focus movement.
Authors should not specify the interestfor attribute to
target a "rich" popover (one containing semantic or interactive content beyond plain text and
images) on an element that already invokes a popover or disclosure on activation. In that case,
the element with interestfor implicitly exposes aria-expanded and aria-details semantics for its interest target,
which would conflict with the expanded state of the click-triggered popover or disclosure. In
particular, authors should not use interestfor with such a
target on:
an element that invokes a popover via commandfor and a popover-related command (such as "toggle-popover", "show-popover", or "hide-popover"), or via popovertarget; or
an element that already uses an explicit aria-expanded attribute for another purpose (such as a custom
disclosure or custom popover).
This restriction does not apply when the interest target is a
"plain" popover (such as a simple tooltip containing only text or images), because such targets
do not receive implicit aria-expanded or aria-details mappings and therefore do not conflict with a
click-triggered popover or disclosure. If an author does combine these attributes with a "rich"
popover target, the fallback accessibility behavior is defined in HTML Accessibility API
Mappings: when interestfor is combined with a
popover-invoking commandfor or popovertarget attribute, the interest invoker takes precedence
and the implicit aria-expanded and aria-details mappings are tied to the interest
target; when interestfor is combined with an
explicit aria-expanded attribute, the explicit aria-expanded attribute takes precedence.
[HTMLAAM]