🎉 hey, I shipped skillcraft.ai — it shows you which dev skills are in demand

Thought you might find it useful. See what's trending, what's fading, and which skills are getting people hired.

Published
3 min read

CSS :interest-invoker and :interest-target Pseudo-Classes

Style connected UI elements with CSS pseudo-classes that respond to user interest. Interactive examples showing tooltips, forms, and navigation without JavaScript.

CSS is getting new pseudo-classes that let you style elements based on user interest. The :interest-invoker and :interest-target pseudo-classes work with the interestfor HTML attribute to create relationships between elements, enabling interactive UIs without JavaScript.

These pseudo-classes are part of the Open UI Interest Invokers proposal, recently accepted by the CSS Working Group. They handle scenarios where hovering or focusing one element should affect the styling of another element elsewhere in the DOM.

The interest invoker system has two parts: an invoker element with the interestfor attribute, and a target element it references. When a user shows interest in the invoker (by hovering or focusing), both elements can be styled:

  • :interest-invoker matches the element with the interestfor attribute when it’s receiving interest
  • :interest-target matches the element being referenced when its invoker has interest

Both pseudo-classes support functional syntax with partial or total parameters. Partial interest means the user has focused the element but hasn’t activated it (like hovering), while total interest means full activation (like clicking).

Basic Interest Example

I respond to the button

How it works

/* Style the invoker when showing interest */
:interest-invoker {
  background-color: lightblue;
}

/* Style the target when its invoker has interest */
:interest-target {
  border-color: blue;
  background-color: lightblue;
}

Traditional CSS requires elements to be in specific DOM relationships (parent-child, siblings) to affect each other’s styles. Interest invokers break that limitation—any element can invoke interest in any other element via IDREF.

The HTML uses the interestfor attribute to establish the connection:

<button interestfor="tooltip-1">Hover me</button>
<div id="tooltip-1">Tooltip content</div>

Then CSS can style both the invoker and target:

/* Style the button when showing interest */
:interest-invoker {
background-color: lightblue;
}
/* Style the tooltip when its invoker has interest */
:interest-target {
opacity: 1;
visibility: visible;
}

One of the most common use cases is creating connected tooltips without JavaScript. When you hover over a button or link, you want to show additional information elsewhere on the page. The interest pseudo-classes make this trivial.

Connected Tooltips

Save your changes (Ctrl+S)
Copy to clipboard (Ctrl+C)
Share with others

CSS with interest pseudo-classes

/* Show tooltip when its invoker has interest */
:interest-target {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

Another powerful use case is highlighting navigation items when their corresponding sections are in view or being interacted with. This creates a connected experience where different parts of your interface respond to user attention.

Interactive Navigation

Home

Welcome to the home section

About

Learn more about us

Services

Our services overview

Contact

Get in touch with us

Navigation highlighting

/* Highlight nav item when it has interest */
:interest-invoker {
  background-color: white;
  color: black;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

Form Field Relationships

Forms often have helper text, validation messages, or related inputs that should respond to focus on specific fields. Interest pseudo-classes make these relationships explicit and maintainable.

Form with Contextual Helpers

We'll never share your email

Must be at least 8 characters

Choose a unique username

Form field relationships

/* Highlight input when focused */
:interest-invoker {
  border-color: blue;
  ring: 2px solid rgba(0,0,255,0.2);
}

/* Style helper text when input has interest */
:interest-target {
  opacity: 1;
  transform: translateY(0);
}

Browser Support and Fallbacks

These pseudo-classes are newly accepted by the CSS Working Group (July 2025) and have no browser implementations yet. The proposal is part of the Open UI initiative, not CSS Selectors Level 5. For production use, you’ll need JavaScript fallbacks or progressive enhancement.

You can detect support using CSS @supports:

@supports selector(:interest-invoker) {
/* Your interest pseudo-class styles */
}

The examples on this page use JavaScript to simulate the behavior until browsers ship support.

The CSS Working Group accepted the :interest-invoker and :interest-target proposal in July 2025, marking a significant step toward declarative interactive UI in CSS. Browser implementations will take time, but the Open UI initiative is actively working to standardize these patterns.

The proposal also includes plans for additional functionality, like the interest-delay-start and interest-delay-end CSS properties to control timing, and a potential possible parameter (currently deferred) for handling focusability edge cases.


Found this article helpful? You might enjoy my free newsletter. I share dev tips and insights to help you grow your coding skills and advance your tech career.


Check out these related articles that might be useful for you. They cover similar topics and provide additional insights.

Webdev
3 min read

NPQ: Open source CLI tool that audits and protects your npm installs from malicious packages

A CLI tool that checks packages for security issues and social engineering attacks before they hit your project

Jul 26, 2025
Read article
Webdev
3 min read

CSS content-visibility: The Web Performance Boost You Might Be Missing

The content-visibility CSS property delays rendering an element, including layout and painting, until it is needed

Dec 5, 2024
Read article
Webdev
13 min read

10 Essential Terminal Commands Every Developer Should Know

List of useful Unix terminal commands to boost your productivity. Here are some of my favorites.

Aug 21, 2024
Read article
Webdev
4 min read

Speed Up Your Website With rel='preconnect' and increase PageSpeed Insights Score

Using link rel='preconnect' can improve your website's performance by reducing connection setup times to key external domains.

Sep 13, 2024
Read article
Webdev
3 min read

::details-content: style expandable content without wrapper divs

The ::details-content pseudo-element lets you style the expandable content of details elements separately from the summary, no divs needed.

Nov 11, 2025
Read article
Webdev
8 min read

Stop Using localStorage for Sensitive Data: Here's Why and What to Use Instead

Understanding the security risks of localStorage and what to use instead for tokens, secrets, and sensitive user data

Oct 28, 2024
Read article
Webdev
3 min read

The HTML Native Search Element

The search HTML element is a container that represents the parts of the web page with search functionality

Dec 2, 2024
Read article
Webdev
4 min read

LH and RLH: The CSS Units That Make Vertical Spacing Easy

Exploring new CSS line-height units that eliminate guesswork from vertical rhythm

Dec 3, 2024
Read article
Webdev
4 min read

How To Implement Content Security Policy (CSP) Headers For Astro

Content Security Policy (CSP) acts like a shield against XSS attacks. These attacks are sneaky - they trick your browser into running malicious code by hiding it in content that seems trustworthy. CSP's job is to spot these tricks and shut them down, while also alerting you to any attempts it detects.

Oct 16, 2024
Read article

This article was originally published on https://www.trevorlasn.com/blog/css-interest-pseudo-classes. It was written by a human and polished using grammar tools for clarity.