CSS Selector Tester

Test selectors against HTML.

About this tool

Try a CSS selector against a small HTML sample in the browser. Matches are listed so you can debug querySelector assumptions.

How to use

Edit the selector and HTML sample, run Test, read match count and snippets. No network — all local DOMParser work.

Example

Sample HTML includes a .card with a child heading and a sibling without the class.

Input

div.card > h2

Output

1 match(es): <h2>…</h2>

Tip

Great for teaching :nth-child and descendant vs child combinators.

Good to know

Does my HTML get sent anywhere?

No. The sample is parsed with the browser's own DOMParser on this page, and the selector is run with querySelectorAll.

Why does a valid selector return zero matches?

Usually a combinator or class name is off by one level. Check child (>) versus descendant (space) and compare the class spelling against your sample markup.

Chrome Extension