HostBaseline · Widely available
The :host CSS pseudo-class selects the containing element of the shadow tree in which it is used. The :host() CSS pseudo-class selects the that element only if it matches the provided selector.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.
Browser support
DesktopChrome
1–53Not supported
54+Supportedsince Oct 12, 2016
Current: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–62Not supported
63+Supportedsince Oct 23, 2018
Current: 157Safari
1–9.1Not supported
10+Supportedsince Sep 20, 2016
Current: 27MobileChrome Android
18–53Not supported
54+Supportedsince Oct 19, 2016
Current: 155Firefox Android
4–62Not supported
63+Supportedsince Oct 23, 2018
Current: 157Safari iOS
1–9.3Not supported
10+Supportedsince Sep 13, 2016
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: :host.
Feature detection
CSS · check before using
@supports selector(:host(*)) {
/* styles that use :host(*) */
}
/* or in JavaScript */
if (CSS.supports("selector(:host(*))")) {
// use it
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (2). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| host | 54 | 79 | 63 | 10 | 54 | 63 | 10 |
| hostfunction | 54 | 79 | 63 | 10 | 54 | 63 | 10 |