Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Chrome DevTools: Inspect & Debug Web Pages

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Chrome DevTools is a set of web authoring and debugging tools built directly into the Google Chrome browser. With it, you can inspect the HTML and CSS of any page, monitor network activity, test JavaScript in real time, and diagnose performance issues. This guide walks you through the core workflows step by step, assuming you have Chrome installed and a page you want to examine.

What You'll Need

  • Google Chrome (any recent version, desktop)
  • A web page to inspect (any site, or a local HTML file)
  • Basic familiarity with HTML, CSS, and JavaScript is helpful but not required

Step-by-Step

  1. Open DevTools. Right-click anywhere on the page and select “Inspect,” or press F12 (Windows/Linux) or Cmd+Option+I (Mac). The DevTools panel opens, docked to the side or bottom by default. You can change the dock position via the three-dot menu (⋮) in the top-right of DevTools.
  2. Inspect an element. Click the cursor icon (top-left of DevTools, or press Ctrl+Shift+C / Cmd+Shift+C) and then click on any element in the page. The Elements panel highlights that element in the DOM tree and shows its CSS rules on the right.
  3. Edit HTML live. In the Elements panel, double-click any tag, attribute, or text to edit it. Changes apply immediately to the page. For example, change the text of a heading to see it update. Refresh the page to revert.
  4. Edit CSS live. In the Styles pane (right side of Elements), click any property value to change it, or click “element.style” to add a new declaration. You can also toggle checkboxes to enable/disable rules, and add breakpoints on CSS rules (right-click a rule → “Add breakpoint on…”).
  5. Run JavaScript in the Console. Click the “Console” tab (or press Esc while in any panel to open the console drawer). Type a JavaScript expression, e.g., document.title, and press Enter to see the result. You can also execute multi-line code by pasting it.
  6. Set breakpoints in JavaScript. Go to the “Sources” panel, open a JavaScript file from the file tree, and click on the line number where you want to pause execution. Reload the page or trigger the event that runs that code. Execution pauses, and you can inspect variables in the “Scope” pane, step through code with the buttons (Step over, Step into, etc.), and hover over variables to see their values.
  7. Monitor network requests. Open the “Network” tab and reload the page. You’ll see a list of all resources loaded (HTML, CSS, JS, images, API calls). Click any request to see its headers, preview, response, and timing. Use the filter bar to show only XHR/Fetch requests, or search for a specific file.
  8. Check performance. Open the “Performance” tab, click the record button (circle), interact with the page (scroll, click, type), then stop recording. You’ll get a flame chart showing where time is spent. Look for long yellow (script) or purple (rendering) blocks.
  9. Test responsive design. Click the device toolbar icon (a rectangle with a phone silhouette, or press Ctrl+Shift+M / Cmd+Shift+M). Choose a device preset or drag the viewport edges to simulate different screen sizes. This is useful for debugging mobile layout issues.
  10. Use the Application panel. Here you can inspect storage: cookies, local storage, session storage, IndexedDB, and service workers. Select a key to view its value, or clear storage from the “Storage” section.

Common Mistakes

  • Forgetting to refresh after edits. Live edits are temporary; they vanish on reload. If you need to persist changes, copy them to your source files.
  • Editing the wrong element. When clicking inspect, make sure you click the exact element you want. If you miss, the wrong node gets selected. Use the arrow keys in the Elements panel to navigate up/down the DOM tree.
  • Confusing CSS specificity. If your style changes don’t apply, a more specific rule is overriding them. Check the Styles pane for crossed-out properties and look for the winning rule.
  • Setting breakpoints in minified code. Minified JavaScript is hard to debug. Use the “Pretty-print” button ({} icon) in Sources to format the code before setting breakpoints.
  • Ignoring the console for errors. Many bugs are logged as errors in the console. Always check the console first when something isn’t working.

Tips

  • Use the command menu. Press Ctrl+Shift+P (or Cmd+Shift+P) to open the command palette. Type any action, like “Capture full size screenshot” or “Disable cache,” to run it quickly.
  • Simulate network conditions. In the Network tab, use the dropdown to throttle to “Slow 3G” to see how your page loads on a slow connection.
  • Inspect animations. In the Elements panel, right-click an animated element and select “Inspect.” Then open the “Animations” drawer (via the ⋮ menu → More tools → Animations) to see and control all CSS animations on the page.
  • Use “Force state” for hover effects. In the Styles pane, click the “:hov” button to force the element into :hover, :active, :focus, etc. states to inspect those styles without actually hovering.
  • Copy as fetch. In the Network tab, right-click a request and select “Copy” → “Copy as fetch” to get a ready-to-use fetch() snippet for testing in the console.

Troubleshooting

  • DevTools won’t open. Try pressing F12 again, or use the menu: Chrome menu (⋮) → More tools → Developer tools. If the shortcut is blocked by your OS or browser extension, use the menu method.
  • Changes don’t appear on the page. Make sure you’re editing the correct element and that the style isn’t overridden. Also check if the page uses a framework that re-renders the DOM; your edits may be overwritten by JavaScript. Use the console to verify the element’s state.
  • Breakpoints aren’t hitting. Ensure the file you’re debugging is the one being executed (check the Network tab for the source file). If the code is in a different file or a service worker, you may need to set the breakpoint there. Also, disable “Skip anonymous functions” in the Sources settings if your code is wrapped.
  • Network tab is empty. Make sure you’re on the Network tab and then reload the page. Some requests may be blocked by ad blockers or extensions; try incognito mode to rule that out.
  • Performance recording shows nothing. You may have recorded too short a time. Record for at least 2–3 seconds of interaction. Also, ensure you’re not on a page that’s completely static.
  • Console errors are cryptic. Click the file link next to an error message to jump to the source line. Use the “Sources” panel to set a breakpoint there and inspect the context.

Frequently Asked Questions

  1. Can I edit a website permanently with DevTools? No. DevTools changes are local to your browser session and are lost on page reload. To make permanent changes, you need to edit the source files and deploy them.
  2. How do I inspect an element that disappears on hover? Open DevTools, go to the Elements panel, then right-click the parent element and select “Force state” → “:hover” (or use the :hov button). This keeps the hover state active so you can inspect the child element.
  3. What is the difference between the Elements panel and the Sources panel? The Elements panel shows the live DOM and CSS, and lets you edit them visually. The Sources panel shows the actual files loaded from the server (HTML, CSS, JS) and is where you set breakpoints for debugging.
  4. How do I debug a JavaScript error that only happens on click? Set a breakpoint in the event handler function. Open Sources, find the file with the handler, and click the line number where the function is defined. Then click the element on the page to trigger the event.
  5. Can I inspect a mobile page from my desktop? Yes, use the device toolbar to simulate a mobile viewport. For actual device debugging, you can use Chrome’s remote debugging with a USB connection, but that requires additional setup.
  6. Why do my console.log messages not show up? Make sure you’re on the Console tab and that the “Info” level is enabled (the dropdown next to the filter box). Also, check that your code actually runs—a syntax error might prevent it from executing.