#448 · Developer Tool

CSS Selector Tester

Test a CSS selector against pasted HTML without adding the fragment to the live page. The first line is treated as the selector and the markup begins after a blank line. Matching elements are listed with compact DOM paths, tag names, IDs, classes, and text previews, while invalid selector syntax produces the browser’s actual parsing error.

Developer Input

DOM match report
Ad space

How to use this developer tool

  1. Paste source text or load the representative sample.
  2. Adjust the available parsing option when the tool provides one.
  3. Select Test Selector or press Ctrl/Cmd + Enter.
  4. Review the summary, issues, and copy-ready output before using it.

What this developer tool does

The HTML fragment is parsed into an isolated document and queried with querySelectorAll. A stable, readable path is built from each matched element and its ancestors; no pasted scripts are executed.

The HTML fragment is parsed into an isolated document and queried with querySelectorAll. A stable, readable path is built from each matched element and its ancestors; no pasted scripts are executed.

Browser support determines which modern pseudo-classes can be tested. Dynamic states such as :hover and layout-dependent selectors cannot be simulated in static pasted HTML.

Example

Input

article.card > h2:first-child

<!-- HTML starts after the blank line -->
<main>
  <article class="card"><h2>First</h2><p>Body</p></article>
  <article class="card featured"><h2>Second</h2></article>
</main>

Expected result

Run the sample to see a structured report generated by the same processing logic used for pasted input.

Use cases

  • Review front-end source during a code migration.
  • Create a structured handoff for documentation or QA.
  • Catch input-specific issues before committing generated output.

Tips for reliable output

  • Paste the smallest complete fragment that reproduces the case.
  • Use the sample once to confirm the expected input shape.
  • Review warnings instead of treating a clean report as a guarantee.
  • Keep the original source in version control before replacing it.
  • Test generated output in the target browser or application.

Processing details

The HTML fragment is parsed into an isolated document and queried with querySelectorAll. A stable, readable path is built from each matched element and its ancestors; no pasted scripts are executed.

Browser support determines which modern pseudo-classes can be tested. Dynamic states such as :hover and layout-dependent selectors cannot be simulated in static pasted HTML.

Frequently asked questions

Does the selector tester run scripts from pasted HTML?

No. DOMParser creates an isolated document and pasted script elements are not executed.

Why does a valid selector return zero matches?

The selector may not match the supplied static markup, or it may depend on a dynamic state such as hover.

Which selector syntax is supported?

Support follows the browser running the page, including its implementation of modern pseudo-classes.

How should I separate the selector from the HTML?

Put the selector on the first section, add a blank line, and paste the HTML after that blank line.

Can the tool test pseudo-elements such as ::before?

No. Pseudo-elements are generated boxes rather than DOM elements, so querySelectorAll cannot return them.

Output fields

FieldMeaning
SummaryCount and outcome of the current run
InterpretationWarnings and practical review guidance
ExportsCopy-ready output plus CSV or JSON when available

Explore HTML, CSS & JavaScript Tools

Browse related browser-based utilities for inspecting and transforming front-end source.

View category hub