Skip to main content

Glossary

CSS Selector

A CSS selector is a pattern used to identify and extract specific elements from an HTML document, based on element type, class, ID, attribute, or hierarchy. Scrapers use them — via libraries like BeautifulSoup, Cheerio, or Playwright — to pull specific fields from page markup.

CSS selectors are often more stable than XPath for scraping because they are tied to visual presentation rather than exact document hierarchy. When a site redesigns its HTML structure, selectors break — building robust selectors that target semantic attributes (data-* attributes, aria roles) rather than class names reduces maintenance burden because semantic attributes tend to be more stable than presentational class names.