Every browser ships with the developer tools, and they are the fastest way to answer "what is this element, where does this style come from, and what did the server actually send".
You can inspect any page that you can see, including the sites that you did not build. That is how most developers learned their craft.
The previous lesson in this module covered "How Do You Write and Open Your First Web Page?", and the next lesson in this module is about "How Do You Attach CSS to a Page Three Different Ways?".
How do you open them?
You right-click anywhere on a page and you choose Inspect, or you press F12, or you use the keyboard shortcut Ctrl + Shift + I on Windows and Linux, and Cmd + Option + I on macOS.
The tools dock to the right or to the bottom, and you can undock them into a separate window if that helps you.
Elements the live DOM tree, and the CSS that applies to the selected node
Console run JavaScript against the page you are looking at
Network every request the page made, with size, time and status
Sources the actual files, with breakpoints for JavaScriptThose four panels cover almost everything that a beginner needs. The others, which are the performance, the memory, and the application panels, come later.
What can I do in the elements panel?
The elements panel shows the live document tree, and not the source that you sent.
That distinction matters. Any change that your JavaScript makes to the DOM appears here immediately, and that is often how you find out that a script rebuilt an element and broke your layout.
1. Click the inspect icon in the top-left of the panel
2. Hover over an element on the page — it highlights
3. Click it — the tree selects the matching nodeWith a node selected, the styles panel on the right shows every rule that applies, in the cascade order, with the winning declaration crossed out where a later rule overrides it.
The top box is the final computed value, and that is the one that actually renders.
When a rule does not seem to apply, this panel tells you why. There is a crossed-out declaration, there is an invalid value, or there is a selector that does not match.
What is the console for?
The console runs the JavaScript in the context of the page that you are looking at. It is a scratchpad and a debugger at once, and the $ family of shortcuts makes it genuinely fast to work with.
// inspect the live page
document.title
document.querySelectorAll('a').length
document.querySelector('h1').textContent
// $0 is the element you last selected in the elements panel
$0.tagName
$0.className
$0.getBoundingClientRect().width
// a quick log of anything
console.table([{ name: 'Ada', role: 'engineer' }, { name: 'Grace', role: 'admiral' }])Two features are worth learning early.
The console keeps the last result in the $_, so you can inspect it, and right-clicking an object in the output gives you a shortcut to copy its path.
And because the console is live, you can fix a broken style as you look at it. You select a node, you change a value in the styles panel, and you watch the page update.
That is the fastest feedback loop in web development, and it is how you learn what a property actually does.
Can I copy the CSS from a site that I like?
You can, and it is a normal part of the learning.
You select an element, you right-click the rule in the styles panel and you copy it, or you use the "Copy declaration" and the "Copy rule" options.
What you get is the rule exactly as the site writes it. That is often a starting point and not an answer, because it may rely on custom properties, on a framework, or on a cascade that you cannot see in one rule.
what you see in the styles panel
.site-header { display: flex; align-items: center; }
what the site actually uses
.site-header { display: flex; align-items: center; gap: var(--gap-3); }
where --gap-3 is defined in :root { --gap-3: 1rem; }You use what you find as a starting point, and then you rebuild it yourself.
The point of inspecting other people's pages is to understand the technique. Copying a rule without understanding the technique teaches you nothing, and it can pull in a broken dependency.
What does the network panel tell me?
Every request that the page made, in order, with the status code, the transferred size, and the time.
Two questions come up constantly. Which request is slow, and which one failed.
Sorting by the size usually points at the images, and a 404 or a 500 in the list is a bug that you can fix immediately.
Status Meaning
200 the response body is in this row
304 the browser already had a fresh copy
301/308 moved permanently — the browser followed it
404 the server could not find that file
500 the server failed while producing the pageWhich panel should you open first?
When a page looks wrong, the fastest route is usually the elements panel. You click the offending element, you read the markup, and you look at the Computed pane to see the final value of every property that the cascade settled on. That tells you what the browser decided, and that is the fact that you were trying to guess.
When a page feels slow, the network panel is the one that you open. It lists every request that the page made, how long each one took, how large it was, and where the time went.
The waterfall view is where the story usually is. There is a blocking stylesheet in the head, there is an image that is far larger than the space it occupies, and there is a script that had to wait for a font.
The console is the third stop. It shows the errors that the page threw, the warnings that a developer left behind, and it lets you evaluate expressions against the live page.
It is also where you can check a hypothesis directly. You type a value in the console, and you look at what the page does.
<!-- run this in the console to see how wide the viewport really is -->
window.innerWidth
<!-- the same measurement, expressed as a custom property -->
getComputedStyle(document.documentElement).getPropertyValue('--content-width')Two habits make the devtools genuinely fast.
You keep the device toolbar open while you work, because a layout that looks right at one width is often broken at another.
And you use the "Inspect element" cursor, which is the little box icon, instead of hunting through a long DOM tree for the element that you want.
When you have found the cause, you fix it in the source file and not in the styles pane. The devtools edit is temporary, it is not saved, and it disappears on the next refresh. But it is the fastest way to test a hypothesis before you change anything permanent.
Quick reference
- You right-click, you inspect, or you press F12. The tools are in every browser.
- The elements panel shows the live DOM, and the styles panel shows every matching rule and the computed value.
- The console runs the JavaScript on the current page, and the $0 is the selected element.
- Editing a value in the styles panel updates the page instantly. It is the fastest way to learn the CSS.
- The network panel shows the status, the size, and the time for every request.
- You copy the other people's CSS as the inspiration, and then you rebuild it yourself.
Try it yourself: you open a site that you use every day, you inspect its header, and you find the CSS rule that controls the background colour. You change it live in the styles panel. Then you open the console, you run document.querySelectorAll('a').length, and you use the $0 on a link that you select in the elements panel.