← All text tools

CSS Selector Tester

Test a CSS selector against pasted HTML, see the match count, the highlighted elements, their paths and the specificity of the selector.

  • Free
  • No sign-up
  • Works on any device

About CSS Selector Tester

Check what a CSS selector actually selects before it goes into a stylesheet or a script. Paste a piece of HTML, type a selector such as ul.menu > li:not(.active) a, and the tool counts the matches, highlights each matched element's opening tag in the parsed markup, and lists their paths and text. It uses your browser's own selector engine on an inert copy of the document, so no scripts run. The specificity is calculated as ids, classes and types, with :is(), :not() and :has() taking their most specific argument and :where() counting as zero.

How to use CSS Selector Tester

  1. Paste the HTML you want to test, or keep the sample.
  2. Type a CSS selector, or a list separated by commas.
  3. Read the count, the highlighted tags, the element list and the specificity.

Why use this tool?

Also known as

Frequently asked questions

Why does the highlighted HTML differ from what I pasted?

The browser parses it like a real page and repairs it, for example adding missing html and body tags and closing open elements. The matches are on that repaired document.

What is the specificity of #nav .item a?

It is (1,1,1): one id, one class and one element name. A higher id count always beats any number of classes, and classes beat any number of element names.

Why does :hover never match anything?

A pasted page has no mouse or focus state, so selectors that depend on user action cannot match. Test the structural part of the selector instead.

Is CSS Selector Tester free?

Yes. CSS Selector Tester on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Can I put CSS Selector Tester on my own website?

Yes. Use the Embed on your site button under the tool to copy a short piece of code and paste it into your page. It is free, needs no account, and the tool keeps working inside your page.

Related tools