CSS Selector Tester
Test a CSS selector against HTML and see every element it matches. Paste markup, enter a selector such as ul.menu > li:not(.hidden) a[href^='https'], and get the count, tag, text and markup of each match. It is useful for scraping rules, end-to-end test locators and querySelectorAll calls.
Frequently asked questions
Which selectors are supported?
Type, class, ID and attribute selectors with all operators, the descendant, child, adjacent and general sibling combinators, and pseudo-classes such as :not, :is, :has, :first-child, :last-child, :nth-child, :nth-of-type, :empty and :checked.
Are there selectors that browsers do not have?
Yes. :contains(text) matches elements whose text includes the given string, a common extension in scraping libraries. Browsers do not support it in querySelectorAll, so avoid it in front-end code.
Does the result match what a browser would find?
For most markup, yes. The HTML is parsed leniently but without every browser repair: for example, a table without tbody is not given one, so tbody tr matches nothing unless tbody is in your markup.
In which order are matches listed?
In document order, the order in which elements appear in the markup, just like querySelectorAll. An element matched by several parts of a selector list is listed once.
How many matches are shown?
The total count is always shown, and the first 500 matches are listed with their tag name, text and markup. Long markup is shortened to 2,000 characters per match.
Why is my selector reported as invalid?
The selector could not be parsed, for example because a bracket or quote is not closed or a pseudo-class is unknown. The message names the problem so you can fix the selector.