Open, close and move the browser's developer tools (DevTools).
What it does
Every desktop browser comes with developer tools, a set of panels for looking inside the page you have open. You can read the HTML, change CSS on the spot, run JavaScript and watch every file the page downloads. Changes made there stay in your browser only, and a reload puts the page back the way it was.
How to open it
Press F12 or Ctrl+Shift+I (Mac: Cmd+Option+I). You can also right-click any part of the page and choose Inspect.
Step by step
Open any page and press F12. The tools appear at the side or bottom of the window.
Press F12 again, or click the X at the top right of the tools, to close them.
Right-click a button or heading and choose Inspect. The tools open with that element already selected.
To move the tools, open the three-dot menu at the top right of DevTools and pick a dock side: bottom, left, right or a separate window.
In Chrome and Edge, Ctrl+Shift+D (Mac: Cmd+Shift+D) jumps back to the previous dock position.
In Safari, turn on the developer features in Settings first (see the table), then press Cmd+Option+I.
Try it in this playground
Paste the example into the lab and run it. Right-click the pink button in the result pane and choose Inspect. DevTools opens with the button's tag highlighted in the HTML tree. Open in the playground
Browser
How to open
Good to know
Chrome
F12, Ctrl+Shift+I, Mac Cmd+Option+I, right-click > Inspect
Main panels: Elements, Console, Sources, Network, Application, Performance, Lighthouse
Edge
Same keys as Chrome
Built on the same engine as Chrome, so the panels and keys match
Firefox
F12, Ctrl+Shift+I, Mac Cmd+Option+I, right-click > Inspect
Some panels have other names: Inspector, Debugger, Storage
Safari
Cmd+Option+I, or right-click > Inspect Element
Turn it on first: Safari > Settings > Advanced > Show features for web developers (older versions: Show Develop menu in menu bar)
Keys and names
F12
open or close DevTools (Windows, Linux)
Ctrl+Shift+I
open or close DevTools (Mac: Cmd+Option+I)
Inspect
right-click menu item that opens DevTools on that element
Dock side
where the tools sit: bottom, left, right or own window
Ctrl+Shift+D
switch to the previous dock position (Chrome, Edge; Mac: Cmd+Shift+D)
Where people get stuck
If F12 does nothing on a laptop, the F keys may be set to volume or brightness; hold Fn and press F12, or use Ctrl+Shift+I. Some school or office computers turn DevTools off by policy.
Elements
See the page as a live HTML tree and change its HTML and CSS on the spot.
What it does
The Elements panel shows the page as a tree of tags on the left and the CSS rules for the selected tag on the right. You can edit both and see the result at once. It is the quickest way to find out why a box is too wide, a color is off, or a rule does not apply. Firefox calls this panel Inspector.
How to open it
Press Ctrl+Shift+C (Mac: Cmd+Shift+C) and click something on the page, or right-click it and choose Inspect.
Step by step
Press Ctrl+Shift+C, move the mouse over the page and click a box. Its tag is selected in the tree.
Double-click a tag name, an attribute or some text to change it. To rewrite a whole block, right-click the tag and choose Edit as HTML.
In Styles, untick the checkbox next to a property to switch it off. Click a value to type a new one; the Up and Down keys change numbers by 1, with Shift by 10.
Click + (New Style Rule) to add a rule for the selected element, or click inside element.style to add a property to this one element only.
Open Computed to see the final value of every property and the box model diagram: margin, border, padding and content, in pixels.
Click :hov and tick :hover, :focus or :active. The element keeps that state, so you can style it without holding the mouse still.
Click the flex or grid badge next to a tag in the tree to draw its lines, gaps and areas over the page.
Try it in this playground
Run the example and pick the first card with Ctrl+Shift+C. Untick padding in Styles and watch the card shrink. Pick a button, turn on :hover with :hov and the pink color stays. Click the flex badge on .row to see the gap drawn. Open in the playground
Keys and names
Ctrl+Shift+C
pick an element on the page (Mac: Cmd+Shift+C)
Edit as HTML
right-click item to rewrite a tag and everything inside it
Styles
CSS rules that match the selected element
element.style
inline style on this one element
Computed
final values after every rule is applied
Box model
diagram of margin, border, padding and content
:hov
force :hover, :focus, :active and other states
flex / grid badge
click to show the layout overlay
H
hide or show the selected element (Chrome, Edge)
Where people get stuck
Everything you change here is gone after a reload, so copy the working CSS back into your file. A struck-through line lost to another rule or has a value the browser does not accept.
Console
Read messages from your code and run JavaScript right on the page.
What it does
The Console lists what your scripts print and every error the browser finds. You can also type JavaScript there and it runs on the open page at once, which is handy for testing a line or reading a value. Messages show the file and line they came from, so you can jump to the code.
How to open it
Press Ctrl+Shift+J (Mac: Cmd+Option+J) to open DevTools on the Console. In Firefox it is Ctrl+Shift+K (Mac: Cmd+Option+K).
Step by step
Open the Console with Ctrl+Shift+J, or open DevTools and click the Console tab.
In your code, console.log prints plain values, console.warn prints a yellow line and console.error a red one. console.table shows an array of objects as a table.
Click the file name and line number at the right of a message to open that line in Sources.
Pick an element in Elements, come back to the Console and type $0. It stands for the element you picked; try $0.textContent.
Type in the Filter box to show only lines that match, or use the levels menu (Chrome: Default levels) to hide info or warnings.
Type 0.1 + 0.2 or new Date() and press Enter to get the answer at once. Shift+Enter adds a new line without running.
Clear the list with Ctrl+L (Mac: Cmd+K) or by calling console.clear().
Try it in this playground
Run the example, then open the Console. You will see a table of items, a yellow warning and a red error. Click the file name at the right of the red line to jump to it. Remember that the result pane is a separate frame; see the entry on using DevTools in this lab. Open in the playground
Keys and names
console.log()
print values
console.warn()
yellow warning line
console.error()
red error line with a stack
console.table()
show an array or object as a table
$0
the element selected in Elements
Filter
show only lines with this text
Default levels
menu to hide or show Verbose, Info, Warnings, Errors (Chrome, Edge)
Shift+Enter
new line without running
Ctrl+L
clear the Console (Mac: Cmd+K)
Where people get stuck
If a message does not appear, check that the Filter box is empty and the levels menu has not hidden that type. When you expand a logged object later, you see its values at that moment, which may differ from when the line ran.
Sources
Pause JavaScript on any line and run it one step at a time.
What it does
Sources shows the files the page loaded and lets you stop the code with breakpoints. While paused, you can read every variable and move forward one line at a time. This finds bugs that console.log alone cannot explain. Firefox calls this panel Debugger.
How to open it
Open DevTools and click Sources (Firefox: Debugger). Ctrl+P (Mac: Cmd+P) opens a file by name.
Step by step
Open Sources and pick a file in the left tree, or press Ctrl+P and type part of its name.
Click a line number to set a breakpoint. When the code reaches that line, it stops before running it.
While paused, hover a variable to read its value, or look at Scope on the right for every local value. Add a name to Watch to follow it.
Press F10 to run the next line, F11 to step into a function, Shift+F11 to step out, and F8 to continue until the next breakpoint.
Right-click a line number, choose Add conditional breakpoint and type a test such as p === 450. It stops only when the test is true.
Write debugger; in your code to stop there whenever DevTools is open. Delete it when you are done.
Try it in this playground
Open DevTools first, then run the example. The code stops at debugger; when p is 3000. Press F11 to enter addTax and watch tax and total change in Scope, then F8 to go on. Next, right-click a line number in that file and add a conditional breakpoint with p === 450. Open in the playground
Keys and names
Breakpoint
click a line number to stop there
Conditional breakpoint
stop only when a test is true
debugger;
stop at this line from code
Scope
local and global values while paused
Watch
values you chose to follow
Call Stack
the chain of calls that led here
F8
continue (Mac: F8 or Cmd+\)
F10
next line, step over calls (Mac: F10 or Cmd+')
F11
step into a function (Mac: F11 or Cmd+;)
Shift+F11
step out of a function (Mac: Shift+F11 or Cmd+Shift+;)
Where people get stuck
debugger; does nothing while DevTools is closed. Breakpoints stay after a reload; if the page keeps stopping where you do not expect, remove them in the Breakpoints list.
Network
List every file the page downloads, with status, size and time.
What it does
The Network panel lists every request the page makes: HTML, CSS, scripts, images, fonts and data calls. Each row shows the status code, size and how long it took. It records only while DevTools is open, so open it first and then reload. It is also where you find out why an old file keeps showing after you changed it.
How to open it
Open DevTools, click Network, then press F5 to reload and fill the list.
Step by step
Open Network and reload the page. Each row is one request.
Read Status: 200 is OK, 304 means the browser reused its stored copy, 404 means the file was not found, 500 means the server failed.
Size shows bytes sent over the wire. (memory cache) or (disk cache) means the browser used its stored copy and did not ask the server.
Time and the Waterfall bars show which files are slow. Click a row to see Headers, Preview and Response.
Tick Disable cache. While DevTools stays open, every reload fetches fresh files.
Open the throttling menu (it says No throttling) and pick a slower preset to see how the page loads on a weak connection.
Press Ctrl+Shift+R (Mac: Cmd+Shift+R) for a hard reload that skips the stored copy for this load.
Try it in this playground
Open Network, then run your code in the lab again and watch which rows appear. Switch the throttling menu to a slow preset and run it once more to compare the times. Set it back to No throttling when you finish. Open in the playground
What you see
Likely cause
Try this
Size shows (memory cache) or (disk cache)
The browser used its stored copy
Ctrl+Shift+R, or tick Disable cache and reload
Status 304
The server says the file has not changed
Check that the new file really reached the server, then hard reload
Size shows (ServiceWorker)
A service worker answers with an old copy
Application > Service workers: Unregister, or tick Update on reload
The row asks for an old file name
The HTML still links the old file
Fix the link, or add a version such as style.css?v=2
Still old after all of this
A cache on the server side or in between
Clear that cache, or wait for its time limit
Keys and names
Status
200 OK, 304 not changed, 404 not found, 500 server error
Size
bytes sent, or (memory cache) / (disk cache)
Time / Waterfall
how long each request took and when
Disable cache
always fetch fresh files while DevTools is open
Throttling
pretend to be on a slow connection
Preserve log
keep the list after a reload or page change
Ctrl+Shift+R
hard reload (Mac: Cmd+Shift+R; Windows also Ctrl+F5)
Empty Cache and Hard Reload
right-click the reload button while DevTools is open (Chrome, Edge)
Where people get stuck
Leaving throttling or Disable cache on makes every site slow while DevTools is open. If the list is empty, DevTools was opened after the page loaded; reload once.
Device mode
Shrink the page to a phone or tablet screen inside your desktop browser.
What it does
Device mode shows the page at a phone or tablet size, sends touch events instead of mouse events and can turn the screen sideways. It is a quick check for media queries and small screens. It copies the size and touch, but not the real phone browser, so test on a real phone before release.
How to open it
Open DevTools and press Ctrl+Shift+M (Mac: Cmd+Shift+M), or click the phone and tablet icon at the top left of DevTools. In Firefox it is called Responsive Design Mode (Ctrl+Shift+M, Mac: Cmd+Option+M).
Step by step
Press Ctrl+Shift+M. A toolbar appears above the page.
Pick a device from the Dimensions menu, or keep Responsive and drag the edges to any width.
Click the rotate icon to switch between portrait and landscape.
On mobile presets the pointer turns into a round touch dot and clicks act like taps.
Drag slowly from wide to narrow and watch where the layout breaks. Those widths are where a media query helps.
If the page reads the screen size only once when it loads, reload after changing the device.
Press Ctrl+Shift+M again to go back to the normal view.
Try it in this playground
Run the example and open device mode. Make the screen narrow: once the result pane itself is under 500px wide, the boxes stack and turn pink. The console prints the new width each time the size changes. Open in the playground
Device mode changes screen size, pixel ratio, touch and the browser name the page sees, but the engine stays your desktop one. Small differences can still show on a real iPhone or Android phone.
Application
Read, edit and delete cookies, localStorage and other data a site keeps.
What it does
The Application panel shows what a site has saved in your browser: cookies, localStorage, sessionStorage, IndexedDB and cache storage. You can read each value, change it or delete it. Firefox puts the same things in its Storage panel, and Safari in its Storage tab.
How to open it
Open DevTools and click Application (behind the >> arrow if the tab row is narrow). In Firefox open Storage, or press Shift+F9.
Step by step
Under Storage in the left list, open Cookies and click the site address. Each row shows name, value, domain, path, expiry and flags such as HttpOnly and Secure.
Double-click a value to edit it. Select a row and press Delete to remove it; the clear icon above the table removes them all.
Open Local storage and click the site address to see the key and value pairs saved with localStorage.setItem.
Session storage works the same way but empties when the tab closes.
To start fresh, click Storage at the top of the list (Chrome, Edge) and press Clear site data.
Reload after deleting to see how the page behaves for a first-time visitor.
Try it in this playground
Run the example; it saves a visit number in localStorage. In Application > Local storage, open the run.appdogu.com entry to see the demo-visits key. Delete it and run again: the number starts over at 1. If the console says storage is blocked, the steps still work the same way on any normal page. Open in the playground
Keys and names
Cookies
small values sent to the server with each request
Local storage
key and value pairs that stay after closing the browser
Session storage
like local storage, but cleared when the tab closes
IndexedDB
larger structured data saved by scripts
HttpOnly
cookie that JavaScript cannot read
Clear site data
remove everything this site saved (Chrome, Edge)
Shift+F9
open Storage in Firefox
Where people get stuck
Cookies marked HttpOnly cannot be read from JavaScript, but they still show here. Deleting a login cookie signs you out of that site.
Performance and Lighthouse
Record what slows a page down and get scores for speed and accessibility.
What it does
Performance records what the browser does over time: running scripts, working out styles and drawing the screen. Lighthouse runs a set of checks and gives scores from 0 to 100 for Performance, Accessibility, Best Practices and SEO, with a list of things to fix. Lighthouse is in Chrome and Edge; Firefox has its own Performance panel but no Lighthouse.
How to open it
Open DevTools and click Performance or Lighthouse. If you cannot see them, open the >> arrow at the end of the tab row.
Step by step
In Performance, click the reload-and-record button to record while the page loads, or press Record, use the page, then press Stop.
In the result, look for wide yellow blocks (scripts) and tasks marked in red, which took too long. Click one to see which function ran.
Open the Bottom-Up tab to sort functions by time spent; the slowest are at the top.
In Lighthouse, choose Mobile or Desktop, tick the categories you want and click Analyze page load.
Read the scores. Open the items under each one to see what went wrong and which element it points at.
Fix one thing, run the check again and compare.
Try it in this playground
Run the example with Performance recording: press Record, run the code, then Stop. Find the long task and click it to reach the loop. The console also prints how many milliseconds the loop took. Lighthouse checks the address in the tab, so here it scores the lab page; open your own page in its own tab to score it. Open in the playground
Keys and names
Record
start and stop a recording
Reload and record
record the page load from the start
Long task
a task over 50 ms, marked in red
Bottom-Up
functions sorted by time spent
Lighthouse
scores for Performance, Accessibility, Best Practices, SEO
Analyze page load
start a Lighthouse check
console.time()
measure the time between two points in your code
Where people get stuck
Scores move a little from run to run, and browser extensions can slow the page. A guest or incognito window gives steadier numbers. A high accessibility score is a good start, but some problems only a person can find.
Using DevTools in this lab
Switch the F12 console to the result pane frame to reach your own code.
What it does
The result pane in this lab is an iframe loaded from run.appdogu.com, a different address from the editor page. DevTools treats it as a separate frame. The F12 console starts on top, the lab page, so your variables and elements are out of reach until you switch the console to the run.appdogu.com frame.
How to open it
Open F12 > Console, click the menu at the top left of the console that says top, and choose run.appdogu.com.
Step by step
Run your code so the result pane shows something.
Press F12 and open Console. At the top left there is a menu that says top.
Open it and choose run.appdogu.com. Code you type now runs inside the result pane, so document.querySelector('h1') finds your heading.
Switch back to top when you want to look at the lab page itself.
In Elements, open the iframe tag and its #document to see your HTML, or press Ctrl+Shift+C and click straight inside the result pane.
For a quick look, use the lab's own Console tab under the editor. It shows console.log lines and errors from the result pane without F12, and clicking a line number takes you to that line in the editor.
Try it in this playground
Run the example, open the F12 console and type myGreeting while the menu says top: you get a ReferenceError. Switch to run.appdogu.com and type it again: you get the text. Type document.querySelector('h1').textContent too. Open in the playground
Lab Console tab
F12 Console
Where
Under the editor in the lab
Browser DevTools
What it shows
console.log lines and errors from your code
Messages from every frame plus the browser's own
Clicking a line
Jumps to that line in the lab editor
Opens the line in Sources
Frame choice
Not needed
Pick run.appdogu.com to reach your code
Keys and names
top
the lab page with the editor and buttons
run.appdogu.com
the result pane iframe where your code runs
Lab Console tab
console.log lines and errors from the result pane; click a line number to jump
F12 Console
the full browser console for every frame
#document
the inner page of an iframe in the Elements tree
Where people get stuck
If your variable is "not defined" or querySelector returns null, look at the frame menu first; it is probably still on top. Firefox has a similar frame picker.
DevTools shortcuts
One table of the DevTools keys you will use most.
What it does
These keys work in Chrome and Edge, and most of them in Firefox too. Where Firefox or the Mac differs, the table says so. Most of them work only while DevTools has focus, so click inside the tools first.
How to open it
Keep this table open next to the lab and try each key once.
Step by step
Press F12 to open DevTools and click inside it.
Press Ctrl+Shift+P (Mac: Cmd+Shift+P) and type a word such as screenshot or dock to find any command.
Press Ctrl+P (Mac: Cmd+P) to open a file by name in Sources.
Press Ctrl+Shift+F (Mac: Cmd+Option+F) to search text in every loaded file.
While paused at a breakpoint, use F10, F11, Shift+F11 and F8 to move through the code.
Try it in this playground
Run any example, open DevTools and go through the table from top to bottom. Ctrl+Shift+C, then a click in the result pane, is the one you will use most. Open in the playground
Action
Windows / Linux
Mac
Open or close DevTools
F12 or Ctrl+Shift+I
Cmd+Option+I
Pick an element
Ctrl+Shift+C
Cmd+Shift+C
Open the Console
Ctrl+Shift+J (Firefox: Ctrl+Shift+K)
Cmd+Option+J (Firefox: Cmd+Option+K)
Device mode
Ctrl+Shift+M
Cmd+Shift+M (Firefox: Cmd+Option+M)
Hard reload
Ctrl+Shift+R or Ctrl+F5
Cmd+Shift+R
Command menu
Ctrl+Shift+P (Chrome, Edge)
Cmd+Shift+P (Chrome, Edge)
Open a file
Ctrl+P
Cmd+P
Search all files
Ctrl+Shift+F
Cmd+Option+F (Firefox: Cmd+Shift+F)
Find in this panel
Ctrl+F
Cmd+F
Continue (resume)
F8
F8 or Cmd+\
Next line (step over)
F10
F10 or Cmd+'
Step into
F11
F11 or Cmd+;
Step out
Shift+F11
Shift+F11 or Cmd+Shift+;
Clear the Console
Ctrl+L (Firefox: Ctrl+Shift+L)
Cmd+K
Switch dock side
Ctrl+Shift+D (Chrome, Edge)
Cmd+Shift+D (Chrome, Edge)
Keys and names
Ctrl+Shift+P
command menu (Chrome, Edge)
Ctrl+P
open a file
Ctrl+Shift+F
search all files
Esc
show or hide the Console drawer under other panels (Chrome, Edge)
Where people get stuck
On many laptops the F keys control volume or brightness; hold Fn with them. In Firefox, Ctrl+Shift+P opens a private window instead of a command menu.