0 / 91
Week 1 · Day 6 of 91

Browser DevTools and evidence-based debugging

Orientation, CLI, and the Web

Objective

Use Elements, Console, Network, and Sources instead of guessing.

Treat the web as a connected system: the browser is a control panel, HTTP is the protocol, the server is the controller, and the database is persistent storage.

  • DOM inspection
  • console errors
  • network requests and status codes

Why this matters

Yesterday you started a server and watched a browser talk to it. Today you see inside that conversation. DevTools turns the browser from a black box into an instrument: the page's live structure, the errors it is already reporting, and every request it makes with the status that came back. This is the day guessing stops. From here on, "it's broken" is not a report — the URL, the method, and the status code are.

The DOM: what the page really is

The server sends the browser HTML, a text file describing the page. The browser parses it and builds a live in-memory tree of objects called the DOM (Document Object Model). Every heading, paragraph, and button is a node in that tree.

The crucial point: the DOM is what is on screen now; the HTML file is only what arrived. Once JavaScript adds and changes nodes, the two drift apart. View Source shows the file; DevTools shows the DOM. When they disagree, the DOM is the truth.

Schematic vs. in-circuit probe

Reading the HTML source is reading the schematic: the design as drawn. Inspecting the DOM is putting a probe on the powered board and reading the actual voltage at each node right now. Boards get modified after manufacture and pages get modified after loading — so when debugging, you trust the probe, not the drawing.

Opening DevTools, and the four panels

F12 opens DevTools in any major browser; on macOS Chrome, Cmd+Option+I. Right-click anything and choose Inspect to jump straight to that element. (Firefox names the first panel Inspector; Safari needs the Develop menu enabled in Settings → Advanced.)

Four panels carry today's work:

  • Elements — the live DOM tree, plus a Styles pane showing every CSS rule matching the selected node.
  • Console — messages the page printed and every error it hit. You can also type JavaScript here and run it against the live page.
  • Sources — the files the browser downloaded, where you can pause execution on a line.
  • Network — every request the page made, with method, status, size, and timing.

Today's work lives in Elements, Console, and Network. Week 4 uses Sources properly.

Console errors are the cheapest evidence you will ever get

An error in the Console is not noise; it is a precise report the browser wrote for you, free, before you asked. Beginners scroll past them. A real one:

Uncaught TypeError: Cannot read properties of null (reading 'value')

Three facts in one line. TypeError — you used a value in a way its type does not allow. null — the thing you reached into was empty, usually because an element you looked for was not found. 'value' — the property you tried to read. The right of the row shows the file and line number. That is the whole diagnosis before you have changed a character.

Uncaught means nothing in the code handled it, so the browser abandoned that work. A page can look "half loaded" for exactly this reason.

Network: methods and status codes

Every request in the Network panel has a method and comes back with a status code.

The method is the verb — what the client wants done. GET fetches, POST sends new data, PUT and PATCH update, DELETE removes. Loading a page is a GET.

The status code is a three-digit number the server sends back, and its first digit is the whole summary:

Range Meaning Examples
2xx Success 200 OK, 201 Created
3xx Redirect — look elsewhere 301 Moved Permanently
4xx Your request was wrong 400 Bad Request, 404 Not Found
5xx The server failed 500 Internal Server Error, 502 Bad Gateway

That 4xx/5xx split decides where you go looking. A 404 means the client asked for something not there — check the URL. A 500 means the server crashed handling a request it accepted — check the server logs. Blaming the wrong side wastes hours.

Ten seconds

Open any site, press F12, switch to Network, reload, count the rows. A modern page is dozens of requests, not one.

The bus analyzer and its ACK

The Network panel is a bus analyzer clipped onto the line: every transaction captured with its address, direction, and the acknowledgement that came back. A status code is that ACK/NAK byte. You do not guess whether the peripheral responded — you read the code it returned.

Walkthrough: inspect a real page

Open https://example.com — a tiny real page — and press F12.

1. Inspect an element. Right-click the heading "Example Domain" and choose Inspect. The Elements panel highlights the matching node:

<h1>Example Domain</h1>

Double-click the text, type Probed live, and press Enter. The page updates instantly — you changed the DOM in your own browser's memory, not the server, not anyone else's view.

2. Change a style locally. With the <h1> still selected, find the Styles pane. In the element.style { } block, click inside the braces, type color: red, press Enter. The heading turns red.

3. Read the Console. Switch to the Console tab and type:

document.title
'Example Domain'

Now deliberately break something:

document.querySelector("#nope").value
Uncaught TypeError: Cannot read properties of null (reading 'value')

No element has id nope, so querySelector returned null, and reading .value off null is the type error. You produced and diagnosed a real error on purpose.

4. Watch the network. Open the Network tab, then reload with Cmd+R / Ctrl+R — the panel records only while open. A row appears for the document. Click it and read the Headers tab:

Request URL:     https://example.com/
Request Method:  GET
Status Code:     200 OK

5. See a failure. With Network still open, go to https://example.com/does-not-exist. The document row now shows status 404: the server answered, it just had nothing at that path.

Checkpoint

Notice what the reload did to your edits: the red heading and "Probed live" are gone. DevTools DOM and style changes are local and temporary — a way to test a change, never to make one.

Using AI today: reviewer mode

Today's mode is reviewer — you bring work you already did and ask the AI to attack it. A useful review produces specific, actionable findings backed by evidence: concrete defects, risks, missing checks, unverified assumptions. General praise is worthless, and a full rewrite is worse — it replaces the thing you were trying to understand.

After your first pass, before concluding anything

"Give me a debugging checklist that starts with observable evidence, not random code changes." Compare its checklist to what you actually did. Anything you skipped is a habit to build.

Your turn

  1. Pick a public page you use — a news site, a shop, a docs page.
  2. Inspect one element and record its tag and text.
  3. Change one style on it in the Styles pane; note exactly what you changed.
  4. Reload and confirm the change is gone. That is the proof it was local.
  5. Open the Network tab, reload, and pick one request. Record its URL, method, and status code from the Headers tab.
  6. Record any Console error already present. If it is clean, create one with the document.querySelector("#nope").value trick and record that.
  7. Write devtools-notes.md with the request URL, method, status, what you changed locally, and one sentence on what the status code told you about who is responsible.

You are looking at a real, live site

Inspecting and editing the DOM affects only your own browser and is safe. Do not use the Console to submit forms, click through checkouts, or send requests on sites you do not own — those actions are real and they leave your machine.

Common pitfalls

  • Opening Network after the page loaded. It records only while open. Open it, then reload.
  • Expecting DevTools edits to persist. They vanish on reload. To keep a change, edit the source file.
  • Reading HTML source and calling it the page. After JavaScript runs, only the DOM is accurate.
  • Treating every red line as fatal. Sites log warnings and blocked-tracker errors unrelated to your problem. Read the message; ask whether it names something you care about.

Verify it yourself

Open today's reference, MDN's Overview of HTTP, and find its section on status codes and request methods.

  1. This lesson claimed 4xx means the client's request was wrong and 5xx means the server failed. Find MDN's wording and check that it agrees.
  2. Find one method MDN lists that this lesson did not mention and write what it is for in devtools-notes.md — from the docs, in your own words.

The hour

  1. 0–5 min Recall

    Without notes, state yesterday’s main idea and one unresolved question.

  2. 5–20 min Learn

    Read only the listed concept notes and official reference sections needed today.

  3. 20–48 min Build

    Open a public webpage, inspect one element, change a style locally, and identify one network request.

  4. 48–55 min Explain and verify

    Run the result, inspect evidence, and explain the data/control flow in your own words.

  5. 55–60 min Quiz and commit

    Complete the quiz, record one lesson, and commit the verified change when applicable.

What to hand in

Deliverable

A devtools-notes.md with the request URL, method, status, and what changed locally.

Working with AI today

AI as skeptical reviewer

Provide existing work and ask for concrete defects, risks, missing tests, and unsupported assumptions—not praise.

Give me a debugging checklist that starts with observable evidence, not random code changes.

References

End-of-day quiz

Q1 Which DevTools panel shows HTTP requests?
Q2 Which result best proves today’s work is complete?
Q3 What should an AI code review primarily produce?

Explain-back gate

Pass the quiz above to unlock completion.

Quiz + explain-back checks required.