Two features in every browser look like they do the same thing and do not. Understanding the difference between them turns developer tools from an intimidating panel into the fastest way to answer almost any question about a page.
View source shows the original file
Viewing source displays the raw text the server sent, exactly as it left the server, before the browser did anything with it. It is a static document with no interactivity.
This is what you want when you need to confirm what was actually delivered. Checking that a meta tag is present, that a template rendered the values you expected, or that a script tag points at the right file are all view source jobs. It is also the view a search engine crawler starts from, which makes it the honest answer to what your page contains before any script runs.
The inspector shows the live document
The element inspector shows the DOM: the tree the browser built and has been modifying ever since. It reflects the parser repairs described earlier, every element a script has added or removed, and every attribute changed since the page loaded.
Open it with the keyboard shortcut for developer tools, or by right clicking any element and choosing to inspect it, which jumps straight to that node in the tree. That second route is the one worth building into muscle memory, because it answers where is this thing in my markup instantly.
When the two disagree
A mismatch between source and inspector is informative rather than alarming, and it has three usual explanations.
- The parser repaired invalid markup. A paragraph you thought contained a div now shows as siblings, which explains a selector that never matches.
- JavaScript modified the page after load. Content present in the inspector and absent from source came from a script, which matters because some crawlers may not see it.
- The browser inserted implied elements. A table body appears in the inspector even when you never wrote one, which is why a CSS rule targeting a row as a direct child of a table fails.
Whenever a page behaves in a way its source does not explain, comparing the two is the first diagnostic step.
The panels worth knowing early
Developer tools contain a great deal you can ignore at first. Four panels cover almost everything a beginner needs.
Elements shows the DOM alongside the styles applied to whatever is selected, with overridden rules struck through so you can see which declaration won and which file it came from. Editing values there is temporary and does not touch your files, which makes it an ideal place to experiment.
Console displays JavaScript errors. A page where something simply does not happen is usually explained by a single red line here, and looking before guessing saves a lot of time.
Network lists every request the page made, with its status. This is where a 404 for a missing stylesheet or image appears, along with the exact address that was requested, which resolves path problems immediately.
The device toolbar simulates narrow screens so you can test responsive behaviour without a phone. It is an approximation rather than a true test, but it catches most layout problems.
Learning from other people's pages
Every page on the web is readable. When you see a layout or component you cannot work out, inspect it. The structure, class names and CSS rules are all there, and reading production markup written by people who do this professionally is a genuinely effective way to learn.
Be aware that large sites are usually built by tooling, so class names may be machine generated and the markup heavily nested. Smaller handwritten sites are often more instructive for that reason.
Copying an element out of the tree
Right clicking a node in the inspector offers options to copy it, and two are particularly useful. Copying the outer markup gives you that element and everything inside it, which is the quickest way to lift a fragment into a test file for isolation. Copying the selector produces a path that will reliably target that one element, which saves working one out by hand when you want to write a rule against something buried several levels deep.
The habit to build
The instinct worth developing is to open the tools before forming a theory. A page that looks wrong prompts most beginners to start changing code and reloading. Inspecting first tells you what the browser thinks is true, and the gap between that and what you expected is nearly always the bug, found in seconds rather than found by elimination.