In Firefox Developer Tools, where the HTML is shown, I would like to see the line number, but line numbers are not shown.

(It's worth mentioning that I am having the same issue in Chrome, as they are similar in this regard.)

Is there a way to show line numbers for HTML?

For example:

  • By making line numbers visible all the time, or...
  • By making the number of a specific line visible when that part of the code is hovered over/clicked/etc.

In the window to the right (of the one in the screenshot above), it is possible to easily check the line number of the current CSS selector.

Clearly developers of both browsers thought it useful to include this feature for CSS.

It seems reasonable that some users might want to check the line number for HTML as well. But so far I have not been able to find it.

1 Answer 1


What you're viewing may appear to be HTML, but it's not really HTML in the sense of a text document that has meaningful line numbers. It's the live Document Object Model (DOM) for the page, and it's the result of the HTML source code (and other page resources) being loaded in by the browser.

Once the HTML is processed by the browser (and JS is executed), it's no longer meaningful for each element to have a line number. The page's JavaScript code may remove some elements and may even create new elements, and these new elements could not have meaningful line numbers because they didn't originate in the document's HTML source code.

If you want to view the page's original HTML source code with line numbers, you can use the browser's "View Source" tool. If you want to work with the live DOM, then you will need to get used to browsers not keeping track of which line of source code originally spawned each live DOM element.

  • 1
    Ah, I see. I had neglected to take dynamically changing DOM elements into account. Makes sense. Thanks for explaining.
    – Mentalist
    Feb 14, 2023 at 5:56
  • 1
    What I found missing in that answer (for completeness) is that the "HTML" is also reformatted. That is lines are merged or split as necessary. Feb 14, 2023 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.