Web Platform Atlas
ENRU⚡UA⚡DE⚡FR⚡ES⚡PL⚡PT⚡ZH⚡JA⚡
Catalog / Selectors Level 4 / Introduction

1 Introduction

Static preview (EN): for MDN, WPT, glossary and BYOK translation open the interactive Atlas.
⚡ Open chapter in Atlas

1. Introduction

This section is not normative.

A selector is a boolean predicate that takes an element in a tree structure and tests whether the element matches the selector or not.

These expressions may be used for many things:

directly on an element to test whether it matches some criteria, such as in the element.matches() function defined in [DOM]

applied to an entire tree of elements to filter it into a set of elements that match the criteria, such as in the document.querySelectorAll() function defined in [DOM] or the selector of a CSS style rule.

used "in reverse" to generate markup that would match a given selector, such as in HAML or Emmet .

Selectors Levels 1, 2, and 3 are defined as the subsets of selector functionality defined in the CSS1, CSS2.1, and Selectors Level 3 specifications, respectively. This module defines Selectors Level 4.