Skip to content
Pricing Failed solves are free. You only pay when it works. See prices

Free tools

CSS selector tester

Paste HTML, type a CSS selector and see every element it matches, with the text and attributes you would extract from each.

Or paste it below. We fetch public pages only, as a plain request with no JavaScript, so a site behind a bot check may answer with its block page.

HTML

Selector

Matches

Paste HTML and type a selector. Every element it matches is listed here.

Extracted values

One value per match appears here.

The same selector in code


            

When to use it

You're writing a scraper and need a selector that picks out exactly the right elements. Paste the page's HTML and try selectors until the matches are right. Then copy the code.

How the matching works

Your browser reads the HTML you paste into a separate, detached document. Then it runs the selector with querySelectorAll. That's the same engine a headless browser uses, so a selector that works here works in Playwright or Puppeteer. Nothing in the pasted page loads or runs. Scripts stay inert and images aren't requested.

Why it matches here but not in your scraper

  • The page you fetched isn't the page you saw. View source shows what the server sent. The element inspector shows the page after its scripts ran. Paste the HTML your scraper actually received.
  • The browser repairs markup as it reads it. It adds tbody inside tables and closes tags left open. So table > tr matches nothing in a browser, but may match in a more forgiving parser.
  • Parsers differ on newer syntax. :has() and :is() work here and in current browsers. Older versions of BeautifulSoup's selector library, and some HTML parsers, reject them.

Selectors that survive a redesign

Choose attributes the site relies on over class names it generates. [data-testid="price"], [itemprop="name"] and a[href^="/product/"] tend to outlast class names like .css-1x2y3z, which change with every build. Keep the selector as short as you can while it still matches only what you want.

Questions people ask

How do I test a CSS selector?

Paste the page's HTML into the box and type the selector. The matches update as you type, with the text and attributes each one would give you.

Why does my selector work in the browser but not in my scraper?

Usually because the browser shows the page after JavaScript has run, and your scraper downloads the HTML before it has. Paste the HTML your scraper actually receives and test against that.

CSS selector or XPath?

CSS is shorter and easier to read for most jobs. Use XPath when you need to match on text, walk up to a parent, or pick an element by its position relative to another.

How do I write a selector that does not break?

Prefer ids, data attributes and meaningful class names over long chains of tags and nth-child. Avoid generated class names like css-1x2y3z, which change every time the site is rebuilt.

Get started

Blocked by bot protection? $5 is 5,000 solves.

No subscriptionCredit never expiresFailed solves are free