CSS Selector Tester

Test CSS selectors against HTML markup and inspect matching elements interactively.

100% Free · No Sign-up · Runs in Your Browser

Quick Selectors:

About the CSS Selector Tester

Writing precise CSS selectors for styling or automated web scraping can be challenging, especially when dealing with pseudo-classes (:nth-child, :first-of-type), attribute selectors ([data-status='active']), and combinators (>, +, ~). This CSS Selector Tester evaluates your selector against an HTML snippet in real time.

This tool is designed for web developers refining styling rules, QA engineers writing Playwright or Cypress selectors, and web scrapers verifying CSS query selectors. It displays all matching elements, their tag names, IDs, classes, and full outer HTML.

To use it, paste your HTML snippet in the left box, enter your CSS selector in the input field, and click 'Test CSS Selector'. The matching elements appear in the results list alongside a total match counter.

For instance, testing '.card > .btn-primary' highlights only primary button elements that are direct children of card containers, allowing you to verify selector specificity immediately.

A common mistake is confusing ':nth-child(n)' with ':nth-of-type(n)'. ':nth-child' counts all sibling elements regardless of tag name, while ':nth-of-type' counts only elements of the same tag.

Tip: Use the preset selector buttons to quickly test common combinations like nav links, cards, and primary buttons.

Frequently Asked Questions

Q.Can I test modern CSS selectors like :has() and :is()?

Yes, because evaluation runs natively in your modern web browser, modern pseudo-classes supported by your browser will work seamlessly.

Q.Can I copy the outer HTML of all matched elements?

Yes, click 'Copy Matches Outer HTML' to copy all matching element snippets.

Q.Is any data transmitted online?

No, selector testing executes locally in an isolated DOM template inside your browser.

Related Tools