Inspect the DOM with developer tools
Developer tools show the browser’s current document, which can reveal how invalid source was parsed or changed by scripts.
✓ What you will learn in this topic
- Explain the purpose of Inspect the DOM with developer tools in a real HTML document.
- Choose and apply the elements shown in both examples.
- Recognize the specific mistake described in this lesson.
Concept explanation
The Elements or Inspector panel displays the live DOM tree, not simply the original file text. Use it to see whether tags were auto-closed, attributes changed, or JavaScript inserted nodes. The console reports script errors and accessibility-related warnings from some tools. Compare the response source with the live DOM when troubleshooting, and use a validator to check markup conformance rather than treating devtools as a full validator.
Syntax
Inspect a node in the live DOM, compare it with the original source, and use validation for conformance errors.
Example 1: a small page
Inspect main and its children to see the document tree the browser built.
<main>
<h1>Reading garden</h1>
<p>Borrow a field guide.</p>
</main>Expected result: The live inspector shows main containing one heading and one paragraph.
Example 2: a practical page
Inspect the label and input attributes to verify their id/for relationship and submitted name.
<form>
<label for=\"topic\">Topic</label>
<input id=\"topic\" name=\"topic\" type=\"search\">
<button type=\"submit\">Find</button>
</form>Expected result: The inspector confirms the input is inside the form and the label targets the correct control.
Common mistakes
Do not assume the browserâs repaired DOM exactly matches the source you wrote.
Best practices
Validate representative pages, inspect the DOM and console, and fix errors at their source instead of hiding warnings.
Practice exercise
Create a page containing three intentional markup errors, use browser developer tools and a validator to find them, then record the corrected markup.
Lesson summary
- The live DOM is the browserâs parsed and modified document; combine inspection with source review and validation.
- Validate representative pages, inspect the DOM and console, and fix errors at their source instead of hiding warnings.
Knowledge check
Does the Elements panel always show the exact original HTML source?
Show the explanation
No. It shows the current DOM after parsing and possibly after JavaScript modifications.
Practical example
html<main>
<h1>Reading garden</h1>
<p>Borrow a field guide.</p>
</main>
Expected result:
The live inspector shows main containing one heading and one paragraph.
Hands-on practice task
Create a page containing three intentional markup errors, use browser developer tools and a validator to find them, then record the corrected markup.
In this section
Other lessons in HTML Validation and Debugging
Broaden your knowledge