Locate an Element Using a CSS Selector in Google Chrome

When you work with Pa11y you may get errors as I described in an earlier blog post:

Sometimes you know exactly where this error comes from. In other times, you may need to use the CSS selector on line 3 to find the problem. Older versions of Chrome had the search for CSS locators at a discoverable spot on the user interface. Unfortunately, these times are long gone.

You can find the search by CSS locator in the developer tools (F12) on the tab “elements”. First select any element in the elements window and then use CTRL+F to open the search box at the bottom of this window:

Hit CTRL+F to open the search box at the end of the elements windows

If you now paste your CSS selector in the search box and hit Enter, the matching element is highlighted in the elements window above.

The element is now highlighted in the elements window above

If you hoover over that selected part of the HTML, Chrome will also highlight the element on the web page:

Hoover over the elements window to see the corresponding element on your web page

This feature is not as discoverable as it was years ago, but as soon as you know the new location you can find your elements without any problems.

1 thought on “Locate an Element Using a CSS Selector in Google Chrome”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.