:state()
Widely availableSince 202495% of users
A pseudo-class for Custom Elements that allows you to style them based on custom internal states (like 'loading', 'active' or 'error') that are set via JavaScript using the ElementInternals API.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since May 2024. Widely available since November 2026.
See how modern your own CSS is.Check your CSS →
Quick example
/* Styles a custom map element when it's in a specific internal 'collapsed' state */
my-map:state(collapsed) {
height: 100px;
overflow: hidden;
}:state() browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2024.Safe to use without fallbacks.
Usage95%of people can use this5% use a browser without it.
Browsers
125+
126+
17.4+
125+Mobile
125+Android
126+Android
17.4+iOS