Back to articles

Using CSS selectors to target content

Projects & CrawlingMay 20, 2026

The Content CSS selector field in the project settings lets you tell FireScraper to extract text only from specific parts of each page. This is optional — if you leave it empty, FireScraper processes the full page using whichever extraction mode you selected.

When to use a CSS selector

Use a CSS selector when:

  • Pages have content you want mixed with content you don't (e.g. blog posts with comment sections, docs with changelog sidebars)
  • You only care about a specific region of the page (e.g. product cards, pricing tables)
  • The default extraction mode includes too much noise for your use case
  • How it works

    When you provide a CSS selector, FireScraper uses it to find matching HTML elements on each page. Only the text inside those elements is extracted. Link discovery (for following links during the crawl) still uses the full page, so the selector only affects what text you get in your results — not which pages get crawled.

    Syntax

    The selector uses standard CSS selector syntax — the same syntax you would use in a browser's document.querySelector(). You can combine multiple selectors with commas.

    Examples

    Extract only the main article body

    article.post-content

    Targets <article class="post-content"> elements. Skips navigation, sidebars, comments, and footers.

    Extract content from a documentation page, ignoring the sidebar

    main .documentation-content

    Targets elements with class documentation-content inside a <main> tag.

    Extract only product cards from a listing page

    .product-card, .product-item

    Matches elements with either class. The comma means "or" — both selectors are matched.

    Extract headings and paragraphs only

    h1, h2, h3, p

    Useful when you want the text structure without lists, tables, code blocks, or other elements.

    Target content inside a specific container by ID

    #main-content

    Matches the element with id="main-content".

    Extract table data

    table.pricing-table td, table.pricing-table th

    Gets all cells from a specific table, useful for pricing comparison scrapes.

    Tips

  • Test your selector first in your browser's DevTools (F12 → Console → document.querySelectorAll('your-selector')) to verify it matches what you expect
  • Use the "Single page" template with depth 0 to test a selector on one URL before running a full crawl
  • Keep selectors simple — complex selectors with many nested combinators can be fragile if the site changes its HTML structure
  • Commas let you match multiple areasmain article, .sidebar-content extracts from both regions
  • The selector field has a 500 character limit — if you need more, your selector may be too specific
  • Was this article helpful?