35

I'm using the Firefox DevTools and I'm using the Inspector tab, in which it displays the HTML tree.

When I use the Search HTML feature, it only searches tags. So suppose I have this:

<div class="lol">textinsidediv</div>

And when I search for 'div', it returns the <div> accordingly. However, if I search for 'textinside' it doesn't match the text inside the content despite the fact that it's starting right there.

My question: How can I search for any arbitrary string within this HTML tree?

(In contrary Firebug performs a simple text search just as expected.)

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
pillarOfLight
  • 8,592
  • 15
  • 60
  • 90

6 Answers6

13

The search in the Inspector panel of the Firefox DevTools allows to search for text content since Firefox 45 (see bug 835896).

Btw. since Firebug 2.0 you're also able to search in the HTML panel using CSS selectors (additionally to the plain text search).

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
11

It is not some really useless html tag search, it actually searches CSS selectors (same as what you use with css, querySelector in Javascript, or jQuery selector)

So you can search #id, go through all elements of a certain class by searching .class, you can even search for all elements with attribute including text, for example [class*="o"] should give all elements with letter o in class attribute. This is helpful for what designers/developers want to find - to find text, you can Ctrl+F within the page, then right click, inspect element.

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
NoBugs
  • 9,310
  • 13
  • 80
  • 146
  • 26
    still relatively useless (about 100x more useless) compared to just a firebug style simple text search which can do all of those above (and many others - including finding text) within split seconds – pillarOfLight Feb 20 '14 at 15:41
  • 1
    CSS searching is what I would think most developers want - the only really annoying thing for me at least is that it doesn't seem to search within frames on the page. What version of Firefox do you have? It may be affected by https://bugzilla.mozilla.org/show_bug.cgi?id=881986 – NoBugs Feb 21 '14 at 02:11
  • 3
    Wow, I had no idea this was how the search box worked. Thank you! – aaronbauman Nov 06 '14 at 18:13
  • Thank you, now i can search by id : `[id*=id_of_the_element]` – inMILD Dec 03 '18 at 05:39
7

A good idea is to Copy Inner HTML but even better is Edit As HTML. That brings up an in-place panel displaying the full text, and it can be searched with Ctrl+F or cmd+F.

Ctrl+G to find next, Ctrl+Shift+G to find previous.

林果皞
  • 7,539
  • 3
  • 55
  • 70
x77686d
  • 111
  • 1
  • 3
  • 1
    what keys to perform "find next" ? – 林果皞 Sep 20 '15 at 08:39
  • 1
    Ctrl+G to find next, Ctrl+Shift+G to find previous. @林果皞 – user Jul 11 '16 at 13:59
  • Yes, right-clicking the outermost element and doing "Edit As HTML" is the best workaround but it's insane that we need a workaround for this. You should just be able to use the search bar to search for text like you would in any other IDE or text editor – Samwise Ganges May 18 '23 at 22:34
3

Workaround: in the inspector, right-click the outermost tag, then click 'Copy Inner HTML'. Paste in a word processor and search there.

Raffi
  • 970
  • 11
  • 13
0

See answer.

As an alternative to searching within dev tools...

  • Right click on the page anywhere
  • Select View Source

Within the source view you can easily perform a text search by doing a ctrl/f or cmd/f if on a mac.

Community
  • 1
  • 1
Kenneth Stoddard
  • 1,409
  • 11
  • 13
0

This is now fixed as of FireFox 45...

https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_HTML#Searching

Kenneth Stoddard
  • 1,409
  • 11
  • 13
  • 3
    if it is fixed would you mind telling us how to do a text search? – Owyn Mar 05 '16 at 20:42
  • Just use the search box, as you would search for a tag. No special characters needed. @Owyn – user Jul 11 '16 at 14:06
  • 1
    I have FF68, and if I type a text string that also happens to be an id or classname, it forces a search using the id or classname. I can't override it. For example, if I had
    test_1 and searched for "test_1", it forces in "#test_1" and will only find the
    .
    – raphael75 Dec 02 '19 at 19:09