DevToys Web Pro iconDevToys Web ProBlog
Rate us:
Try browser extension:

CSS Selector Tester

Error
CSS Selector
DOMParser is not defined

HTML Input

  • Matches

    DOMParser is not defined
    Technical details

    How the CSS Selector Tester Works

    What the Tool Does

    The CSS Selector Tester evaluates CSS selectors against HTML input and visually highlights all matched elements. You paste or type HTML in one panel, enter a CSS selector, and instantly see which elements match with a count of total matches. This provides immediate feedback on selector specificity and scope without needing to open browser DevTools or modify a live page.

    Common Developer Use Cases

    Frontend developers use this tool to craft precise selectors for styling, test scraping selectors against sample HTML before writing extraction code, and debug why a CSS rule is not targeting the intended elements. QA engineers validate Cypress or Playwright selectors against page snapshots. It is also useful for writing content extraction rules for RSS readers, email parsers, or headless browser automation scripts.

    Data Formats, Types, or Variants

    The tool supports the full CSS Selectors Level 3 specification including type selectors, class and ID selectors, attribute selectors with operators ([attr^=value], [attr$=value]), pseudo-classes (:nth-child, :not, :first-of-type), combinators (descendant, child >, adjacent sibling +, general sibling ~), and pseudo-elements (::before, ::after). Complex compound selectors and selector lists (comma-separated) are fully supported.

    Common Pitfalls and Edge Cases

    CSS selector matching depends on the parsed DOM structure, not the raw HTML text — unclosed tags, implicit elements (tbody), and browser error correction can make the actual DOM differ from what you see in source. Pseudo-elements (::before, ::after) are not real DOM nodes and cannot be selected by querySelector. Namespace prefixes in XML/SVG content require special handling. Overly specific selectors that work on sample HTML may break on production pages with slightly different markup.

    When to Use This Tool vs Code

    Use this browser tool for interactive selector development and quick validation against HTML snippets. For production web scraping or test automation, use your framework's built-in selector testing (Playwright's page.locator, Puppeteer's page.$) which runs against the actual rendered DOM with JavaScript execution, dynamic content, shadow DOM traversal, and iframe handling that static HTML matching cannot replicate.