Browser DevTools
You'll learn to open the browser's DevTools and use them to look inside any page.
Watch & read
Start with the required ones. The others are there when you need them.
Explanation
Your page looks wrong. The heading is the wrong colour, or a photo does not show. You stare at your code and it looks fine. You need to see what the browser sees, not what you meant.
Every browser has a toolbox built in, called DevTools. Think of it like a mechanic opening the bonnet of a CNG. From the outside you only see that it will not start. Under the bonnet you can see which part is the problem.
Open it with a right-click on anything and Inspect, or with Cmd + Option + I on a Mac and
Ctrl + Shift + I on Windows. The three panels you need now:
- Elements: your HTML as the browser built it. Click an element and the Styles pane shows every CSS rule on it. Rules that lost are crossed out. You can change a value and see it right away.
- Console: messages and errors. A red line means something broke. It tells you the file and line.
- Network: every file the page asked for, with its status code. A red
404means a file is missing.
<link rel="stylesheet" href="styles.css"><img src="Photo.jpg" alt="My photo">
If the real files are style.css and photo.jpg, nothing shows an error on the page. But the Network
tab shows two red 404s, and you find both typos in a minute.
People often fix a problem perfectly in DevTools, close the tab, and lose it. Changes in DevTools are only in your browser, only until you refresh. When it looks right, copy the change into your real file.
When something looks wrong, check in this order: Console for red errors, Network for 404s, then
Elements to see which CSS rule won.
Code tour
Click a line number with a ring to read the note for that line.
Quick check
3 questions. Each one explains itself after you answer.
- 1 / 3You fixed a colour in the DevTools Styles pane, then refreshed. What happens?
- 2 / 3An image does not show. Where is the quickest place to see if the file was found?
- 3 / 3In the Styles pane, a
colorrule is crossed out. What does that mean?