CSS Selector Tester

All tools

CSS selector

HTML input

Summary

Matches
0
Status
Idle
The preview runs in a sandboxed frame. Matching elements are outlined and numbered.

Matched preview

Matched elements

Test a selector to see matched elements.

About CSS Selector Tester

CSS Selector Tester checks a selector against a block of HTML using the browser's native selector engine.

It is useful when debugging complex selectors, verifying attribute selectors, checking nested markup, or confirming what querySelectorAll would match.

How to use this tool

  1. Paste HTML into the HTML input field.
  2. Enter the CSS selector you want to test.
  3. Click Test selector to view matching elements, paths, and a highlighted preview.

Tips

  • Use the specificity calculator when two matching selectors compete in the cascade.
  • Invalid selectors are reported by the browser selector parser.
  • The preview is sandboxed so pasted markup does not run scripts.

CSS selector checks before using a query in production

Test selectors against representative markup so they match the intended elements without depending on fragile structure or capturing unrelated content.

Positive and negative matches

Include elements that should match, near misses that should not, repeated components, and empty or optional containers.

Dynamic document states

Check markup before and after client rendering, lazy loading, validation, navigation, and state-class changes.

Selector portability

Confirm support for :has(), namespace syntax, escaping, and nonstandard extensions in the exact browser or library that runs the query.

Stable hooks

Use purposeful classes or data attributes for scripts and tests instead of selectors tied to visual nesting or generated class names.

Related tools

You may also find these tools useful.

CSS selector tester FAQ

Does this support modern CSS selectors?
It supports selectors available in your browser's querySelectorAll implementation.
Can I test attribute selectors?
Yes. Attribute selectors such as [data-state='active'] are supported.
Does the HTML execute scripts?
No. The preview is rendered in a sandboxed frame and script-like content is removed before previewing.
Why does a selector fail?
The selector may be invalid, unsupported by the current browser, or simply not match the supplied HTML.