Skip to content

Beginner · How the web works · topic 4 of 64 · 25 min

Browser DevTools: look inside any page

Explanation

Every modern browser has developer tools (DevTools) built in. You can see the HTML and CSS of any page, try changes live, read error messages in the Console, and watch every file the page downloads in the Network tab.

Opening DevTools

On a laptop, press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac), or right-click any part of a page and choose Inspect. DevTools opens next to the page.

Think of it like this: Think of DevTools as an X-ray machine for websites. The page looks normal from outside, but the X-ray shows the bones (HTML), the muscles (CSS) and the nerves (JavaScript) inside.

The main panels

PanelWhat it showsUse it to
ElementsThe live HTML and the CSS of the selected elementFind why something looks wrong; try CSS changes live
ConsoleMessages and errors from JavaScriptRead errors; try small bits of JavaScript
NetworkEvery file and request the page makesSee slow files, 404s and API data
ApplicationStorage such as cookies and localStorageCheck saved data
LighthouseAn automatic report on speed, accessibility and SEOFind what to improve

The Console

Your code can write messages to the Console with console.log(). Errors show up in red with the file name and line number. Reading the error message is the fastest way to fix a bug.

javascript
const prices = [120, 80, 50];
console.log('Number of items:', prices.length);
console.table(prices);
// A typo makes a red error in the Console:
// console.log(price);  -> ReferenceError: price is not defined
console.log prints values; errors tell you the exact problem

Device mode

The phone-and-tablet icon (Ctrl+Shift+M) shows how the page looks on a phone screen. Most visitors in India use phones, so check every page in device mode.

Debugging step by step

  1. Read the error in the Console: what and which line.
  2. Add console.log() before the line to see the real values.
  3. Compare what you expected with what you see.
  4. Fix one thing, save, reload, check again.
Tip: Changes you make in the Elements panel are only on your screen and vanish on reload. Copy a change you like back into your own file.
Careful: Never paste code into the Console because a stranger, a video or a message asked you to. Scammers use this trick to steal logins. Only run code you understand.

Watch the lesson

Browser DevTools: look inside any page · 1/6

F12 or right-click -> Inspect

Every browser hides a powerful toolbox. Press F12 or right-click and choose Inspect.

Prefer a video by a teacher? Find free videos on “chrome devtools tutorial for beginners” on YouTube ↗

In real life: Why is the "Pay" button hidden on mobile?

A tester reports that the Pay button of a fee payment page is missing on phones. The developer opens DevTools, switches to device mode, inspects the button and sees a CSS rule "display: none" inside a media query for small screens. She unticks it in DevTools to confirm, then fixes the rule in the CSS file.

Practice (0/2 done)

Task 1 · Practice

Open any website on a laptop, open DevTools and explore. Change the text of a heading in the Elements panel, change a colour in the Styles pane, type 2 + 2 in the Console, and reload the page with the Network panel open.

Task 2 · Code · Javascript

This function should add up all prices in a cart, but it has a bug: it skips the last item. Find and fix it, so cartTotal([120, 80, 50]) returns 250.

Quick quiz

Question 1

1.Which DevTools panel shows JavaScript errors?

Question 2

2.You change a colour in the Elements panel and reload. What happens?

Question 3

3.Where can you see that an image failed to load with a 404?

Question 4

4.A message asks you to paste some code into the Console to "unlock a free gift". What should you do?

Question 5

5.What does device mode help you check?

Read more (free)

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

← Previous: Your toolkit: editor, browser and folders