Google Chrome Copy CSS Path in Developer Tools

Google Chrome copy CSS Path in Developer Tools

Chrome has updated this option

In chrome after recent update this option has been changed from

(right click on the element in Elements Window) > Copy CSS path
to :

(right click on the element in Elements Window) > Copy > Copy selector

How can I get the CSS Selector in Chrome?

Although not an extension, I did find a bookmarklet called Selector Gadget that does exactly what I was looking for.

Web Developer mode in Chrome or Firefox: how to get an object's CSS full selector?

Right-click the element in the inspector, choose the Copy submenu, and each browser gives you slightly different options:

  • Chrome (and other Chromium-based browsers including the new Microsoft Edge) gives you the option to copy the selector, which produces a somewhat optimized but still fairly long selector that will uniquely identify the element.

  • Firefox gives you two options: "CSS Selector" that functions mostly the same as Chrome but gives you a much more optimized selector, and "CSS Path" that gives you the same as what you're pointing to in your screenshot, the entire path to that element starting from the root. "CSS Path" is designed for web testing tools but it's probably excessive for most other use cases, which I'm guessing is why Chrome doesn't have a similar feature.

Check out these other answers in which I explain a bit more how these features work:

  • How does Chrome dev tools generate CSS selectors?
  • Chrome Dev Tools CSS selectors Method


Related Topics



Leave a reply



Submit