Toolstia / CSS selector tester

CSS selector tester

Paste a piece of HTML and type a CSS selector. The tool shows how many elements match and lists each one, so you can check a selector before you put it in a stylesheet, a test or a scraping script.

The HTML is parsed in a safe, detached document, so scripts in it never run. The selector is tested with the same engine your browser uses, so what matches here will match in your page too.

How it works

  1. Paste your HTML into the first box.
  2. Type a selector such as ul.menu > li:not(.active).
  3. Read the count and the list of matching elements.

Real browser matching

The selector is tested with the same engine your browser uses for stylesheets, so classes, attributes, combinators and pseudo classes such as :nth-child and :not work as they do on a live page.

Safe parsing

The HTML is parsed into a separate document that is never shown on the page. Scripts, images and styles in it are not run or loaded.

Common uses

Writing CSS rules, building test selectors for Cypress or Playwright, and finding elements for a web scraper.

Invalid selectors

If the selector has a syntax error the tool says so, instead of showing an empty result.

Questions

Is my HTML uploaded?

Everything happens in your browser, and nothing you enter is sent anywhere.

Does it support :has()?

Yes, if your browser supports it. Recent versions of Chrome, Edge, Safari and Firefox do.

Why does a selector match nothing?

Check for typos, for a class name written with the wrong case, and for combinators such as > that need a direct parent.