Skip to content

CSS Selectors

Defined

About

The :defined pseudo-class matches any element that is defined. This matches standard element built in to the browser and custom elements that have been defined using customElements.define(). Custom elements that have not (yet) been defined will not match this pseudo-class.

Standard Elements

The selector matches standard element built in to the browser, like a div.

Custom Elements

The selector matches custom elements that have been defined using customElements.define(). The playground defines a custom element called my-custom-element, which is matched by the selector.

Unknown Custom Elements

The selector does not match custom elements that have not been defined. The playground defines a custom element called my-custom-element, but not unknown-custom-element, which is not matched by the selector.

  • Advanced: Open the Browser DevTools and register a custom element called unknown-custom-element to make the selector match