Lesson 6 of 51 · Module 1, lesson 6 of 6 · 5 min
View source and developer tools
Use your browser's tools to see the HTML of any page, including your own.
What you'll learn
- How to see the HTML of any web page with View Source
- How to open the browser's developer tools and inspect an element
- How to change a page temporarily to test an idea
Why this matters
Every browser has tools built in that show you the HTML behind any page. Professional developers use them all day: to find mistakes in their own pages, and to learn how other websites are built. Once you know where they are, the whole web becomes a place to learn from.
View Source: the file as it was sent
View Source shows the HTML file exactly as the browser received it.
| Browser | Windows | macOS |
|---|---|---|
| Chrome, Edge, Firefox | Ctrl + U | Command + Option + U |
| Safari | — | first turn on the developer features (below), then Command + Option + U |
You can also right-click an empty part of the page and choose View Page Source.
Open your own index.html in the browser and press the shortcut. A new tab shows your code, exactly as you typed it.
Developer tools: the page as the browser understands it
The developer tools (often called DevTools) are a panel that opens next to the page. The first tab, Elements (called Inspector in Firefox), shows the page as a tree of elements.
Chrome, Edge and Firefox: right-click anything on the page and choose Inspect. Or press F12, or Ctrl + Shift + I on Windows, Command + Option + I on macOS.
Safari (macOS): first click Safari › Settings…, open Advanced, and tick Show features for web developers (on older versions: Show Develop menu in menu bar). After that, right-click anything on the page and choose Inspect Element.
What you'll see
When you move the mouse over a line in the Elements panel, the matching part of the page is highlighted. It works the other way too: right-click your heading and choose Inspect, and the <h1> line is selected in the panel.
Small triangles (▸ ▾) next to an element open and close it, so that you can see what is inside. <head> usually starts closed.
Source and Elements can be different
View Source shows your file. The Elements panel shows what the browser built from it. Usually they match. But when your HTML has a mistake, the browser quietly repairs it, and the Elements panel shows the repaired version.
For example, if you forget </p>, View Source shows your code without it. The Elements panel shows a </p>, because the browser added one. When a page looks wrong, comparing the two views is a good way to find the mistake.
Change a page — for a moment
In the Elements panel, double-click the text inside your <h1>. Type something new and press Enter. The heading on the page changes at once.
Now refresh the page. Your change is gone. DevTools changes only the copy of the page in the browser's memory. They never change your file. This makes DevTools a safe place to try ideas. When you like a change, make it in VS Code and save.
Try it yourself
- Open a website you use often. Right-click its main heading and choose Inspect. Which tag is it:
<h1>,<h2>, or something else? - Open your own
index.html. Use DevTools to change your heading to your name. Refresh, and watch it change back. - Press
Ctrl + U(orCommand + Option + U) on your own page and compare the source with your file in VS Code.
Common mistakes
- Editing in DevTools and expecting it to last. Changes in DevTools disappear on refresh. Fix: make the real change in VS Code, then save and refresh.
- Feeling lost in a big website's code. Large sites have thousands of lines. Fix: always start by right-clicking the exact thing you are curious about and choosing Inspect. The panel jumps straight to it.
- Nothing happens in Safari. The developer features are off by default. Fix: turn them on in Safari › Settings › Advanced.
Check yourself
- What is the difference between View Source and the Elements panel?
- You changed a heading in DevTools, then refreshed. What happens, and why?
- What is the fastest way to find the HTML of one particular heading on a large website?
Answers
- View Source shows the file as it was sent. Elements shows the page the browser built from it, including any repairs.
- The change disappears. DevTools changes only the copy in the browser, not the file.
- Right-click the heading and choose Inspect.
Next: this first module is complete. Before you move on, build your own first page in the practice exercise. Then, in the next module, you will learn the elements for writing text: headings, paragraphs, emphasis, quotes and more.
my first page
Starter code
Build it in your own folder, on your computer. ZAM students hand this project in on their dashboard, and their mentor reviews it.

