Skip to main content
CSS selectors allow you to target specific HTML elements on a page for monitoring. This is one of the most common and user-friendly methods for content extraction.

How CSS Selectors Work

CSS selectors use the same syntax as CSS stylesheets to identify HTML elements. When you apply a CSS selector as a filter, changedetection.io extracts only the matching elements and monitors them for changes. Key Benefits:
  • Familiar syntax if you know CSS
  • Visual selector tool available in browser mode
  • Multiple selectors can be combined
  • Works with any HTML content

Basic Selector Syntax

Element Selectors

Selects all <p> (paragraph) elements.

ID Selectors

Selects the element with id="price".

Class Selectors

Selects all elements with class="product-title".

Attribute Selectors

Selects elements with a data-price attribute.
Selects elements where href contains “product”.

Practical Examples

Monitor Product Prices

Monitor Multiple Elements

You can monitor multiple elements by entering each selector on a new line:
Each matching element will appear on a separate line in the output.

Extract Specific Table Data

This selects the amount cell in the second row of a pricing table.

Monitor Article Headlines

Extracts the main headline and subtitle from article elements.

Combining Multiple Filters

You can use multiple CSS selectors together to create powerful filters:
This configuration monitors:
  • Product name (by class)
  • Product price (by ID)
  • Stock status (by data attribute)
  • Review summary (by class)
Each element will be extracted and monitored independently.
Monitors the headline, author, date, and first paragraph of news articles.

Advanced Techniques

Pseudo-selectors

Selects items that are NOT sold out.
Selects only the first product.
Selects all text input elements.

Child and Descendant Selectors

Direct children only (immediate <p> elements).
All descendants (any <p> within the container).

Combining Selectors

Very specific: paragraphs with class “highlight” inside elements with class “content” inside a div with id “main”.

Removing Unwanted Elements

Use the “Remove elements” field to exclude parts of the selected content:
This monitors the article body while removing ads, related articles, and scripts.

Testing CSS Selectors

Using Browser DevTools

  1. Right-click on the element you want to monitor
  2. Select “Inspect” or “Inspect Element”
  3. In the DevTools console, test your selector:
  4. Verify it returns the elements you expect

Using the Visual Selector

When using browser-based fetching (Playwright/WebDriver):
  1. Navigate to the Visual Selector tab in your watch settings
  2. Click on elements directly on the page
  3. The CSS selector is automatically generated
  4. Preview the extracted content in real-time

Common Patterns

Pattern: Monitor Specific Divs

Use case: Main content area of a page.

Pattern: Track List Items

Use case: Product listings, search results.

Pattern: Monitor Data Attributes

Use case: Elements with specific data attributes.

Pattern: Extract Meta Information

Use case: Open Graph meta tags for structured data.

Common Pitfalls

Pitfall #1: Selector Too Generic
This will match ALL divs on the page, which is usually too much content.Better: Be more specific
Pitfall #2: Relying on Position
Page structure might change, breaking your selector.Better: Use classes or IDs
Pitfall #3: Not Testing FirstAlways test your selector in browser DevTools before adding it to changedetection.io. Make sure it returns exactly what you expect.

When to Use CSS Selectors

Good for:
  • Monitoring specific sections of HTML pages
  • Tracking product prices and availability
  • Following article content changes
  • Extracting structured HTML content
  • When you need a visual selector tool
Not ideal for:

CSS vs XPath

Debugging Tips

Check What’s Being Extracted

  1. Run a check on your watch
  2. View the Preview tab to see extracted content
  3. Adjust your selector if needed
  4. Run another check to verify

Selector Returns Nothing

  • Verify the element exists on the page
  • Check if the page requires JavaScript (switch to browser-based fetching)
  • Ensure the class/ID names are correct (they may have changed)
  • Try a less specific selector

Extracting Too Much Content

  • Make your selector more specific
  • Add class or ID constraints
  • Use child selectors (>) instead of descendant selectors
  • Use the “Remove elements” filter to exclude unwanted parts

Real-World Examples

Extracts the title from Reddit posts.
Monitors the star count on a GitHub repository.
Extracts tweet text from Twitter/X.
Tracks new job postings with title and salary information.