Edit this page

up.fragment :has()
HTML selector

Your target selectors may use this pseudo-class to replace an element with an descendant matching the given selector.

Example

up.render('div:has(span)', { url: '...' }) replaces the first <div> elements with at least one <span> among its descendants:

<div>
  <span>Will be replaced</span>
</div>
<div>
  Will NOT be replaced
</div>

Compatibility

As a level 4 CSS selector, :has() is currrently implemented in many modern browsers.

Unpoly polyfills :has() so you can use it in target selectors in all supported browsers.