Back to roadmaps html Course
Table of Contents (31 guides)

HTML Debugging: Master Chrome DevTools Inspect Element

When your webpage layout breaks or elements appear in unexpected positions, you don't need to change your code editor and save repeatedly to guess the issue. Modern browsers come with powerful built-in Developer Tools (DevTools). Let's learn how to inspect and debug HTML in real-time.


1. Opening DevTools

In Google Chrome, Microsoft Edge, or Firefox, you can open DevTools using these quick shortcuts:

  • Right-click on any element on the page and select Inspect.
  • Press F12 on your keyboard.
  • Press Ctrl + Shift + I (Windows) or Cmd + Option + I (Mac).

2. Element Panel: Inspecting and Editing the DOM

The Elements panel displays the live HTML Document Object Model (DOM) tree.

A. Live Editing Text Content

  • How: Double-click any text inside an element within the DOM tree. Type a new value and press Enter. The webpage updates instantly! (Note: This is a temporary visual change; refreshing the page will restore the original content).

B. Live Editing Attributes

  • How: Double-click an attribute name or value (like class="user-card" or src="/image.png"). You can change classes, sources, or remove attributes entirely to test edge-case layouts.

C. Dragging and Reordering Elements

  • How: Click and hold any HTML tag in the Elements panel, drag it up or down, and drop it. This instantly shifts the layout positioning, making it easy to test structural changes.

3. Console Panel: Checking for Syntax Errors

If your page features broken images or scripting issues, open the Console tab.

  • Errors in Red: Typically indicate failed asset loadings (e.g., 404 Not Found for missing images or stylesheet paths) or JavaScript runtime errors.
  • Troubleshooting Tip: Always check the Console if a local image doesn't display. It will tell you if the path is invalid.

4. Network Panel: Analyzing HTML File Delivery

The Network panel tracks all resources downloaded by the browser.

  • Check Document Loading Time: Look at the first item in the list (usually your main document file). Check the Waterfall chart to see how long the server took to deliver the raw HTML structure.
  • Disable Cache (A Tester's Best Friend): Check the Disable Cache checkbox at the top of the Network panel. With this enabled while DevTools is open, the browser will ignore local caches and download the latest HTML version on every page refresh.
Published on