View Page Source Chrome: What It Is & How to Use It
In this article
View Page Source in Chrome is a built-in feature that lets you see the raw HTML, CSS, and JavaScript code that makes up a web page. It's a standard developer tool, not a hack or a hidden trick. When you right-click on any webpage and select "View Page Source" (or press Ctrl+U on Windows/Linux, Cmd+Option+U on Mac), Chrome opens a new tab showing the exact code the server sent to your browser. This article explains what that code shows you, how to read it, and why you might want to use it.
What Exactly Is the Page Source?
The page source is the unrendered HTML document that a web server delivers to your browser. It contains the full markup: text content, links, images, meta tags, and often inline CSS or JavaScript. It does not include dynamically generated content—anything created by JavaScript after the page loads (like a live stock ticker or a user's shopping cart) won't appear in the source. For that, you need the browser's DevTools (more on that later).
In Chrome, the source view is a plain text display with syntax highlighting. It's not a live editor; you can't change the code and see the page update. It's purely for reading and copying. The URL of the source view starts with view-source: followed by the page's address, like view-source:https://example.com.
Why Would You Want to View Page Source?
There are several legitimate reasons to look at a page's source code:
- Learning HTML/CSS: You can see how a site structures its headings, paragraphs, and navigation. It's a free tutorial in real-world coding.
- Finding a specific element: If you want to find the exact URL of an image or a link, the source shows the raw path.
- Checking meta tags: SEO professionals often view source to verify title tags, descriptions, and Open Graph tags.
- Debugging your own site: If your page looks wrong, viewing the source shows what the server actually sent, separate from any browser caching.
- Looking for hidden text or keywords: Sometimes you'll spot comments or hidden divs that reveal how a page is built.
It's also a common first step in web scraping or competitive analysis, though for those tasks you'd usually use a dedicated tool or script.
How to Open View Page Source in Chrome
There are three main ways to open the source view:
- Right-click menu: Right-click on any blank area of a webpage (not on an image or link) and choose "View Page Source."
- Keyboard shortcut: Press
Ctrl+U(Windows/Linux) orCmd+Option+U(Mac). - Address bar: Type
view-source:before the URL, e.g.,view-source:https://www.example.com. This works even if you're already on the page.
All three methods open a new tab with the source code. If you want to search within the source, press Ctrl+F (or Cmd+F) and type a keyword.
View Source vs. Inspect Element: What's the Difference?
A common confusion is between "View Page Source" and "Inspect" (or DevTools). Here's the key difference:
- View Page Source shows the original HTML document as sent by the server. It's static and does not reflect any changes made by JavaScript after load.
- Inspect Element (right-click → Inspect, or
Ctrl+Shift+I) opens the DevTools panel, which shows the live DOM (Document Object Model) after JavaScript has run. It also lets you modify CSS and HTML in real time, see network requests, and debug JavaScript.
In short: View Source is for reading the raw file; Inspect is for interacting with the live page. If you're looking for a dynamically loaded element, you won't find it in View Source—you'll need Inspect.
Common Problems and Misconceptions
Here are a few issues people run into:
- "View Source is blank or shows only a few lines." This often happens with single-page apps (like React or Angular sites). The server sends a minimal HTML shell, and JavaScript builds the entire page. The source will look almost empty. Use Inspect instead.
- "I can't see the changes I made to my local file." If you're viewing a local HTML file, make sure you saved the file and refreshed the browser tab. Chrome might be caching the old version—try Ctrl+F5 to force a refresh.
- "View Source shows different code than what I wrote." This can happen if a CMS or framework processes your code (e.g., WordPress adds scripts, minifiers compress CSS). The source is what the server outputs, not necessarily your original file.
- "Is viewing source illegal?" No. Viewing source is a standard browser feature and is legal for any publicly accessible page. Copying and reusing code without permission may violate copyright, but simply looking is fine.
How to Read the Source Code Effectively
Reading raw HTML can be overwhelming. Here's a practical approach:
- Start at the top: The
<head>section contains meta tags, title, and links to CSS/JS files. The<body>contains the visible content. - Use the search function (Ctrl+F) to find specific words or tags. For example, search for "img" to find all images.
- Look for comments (
<!-- ... -->)—developers often leave notes that explain sections. - Ignore minified code (long lines with no spaces). It's compressed for speed. You can use an online formatter to make it readable, but you don't need to for most tasks.
- Check the
<script>tags at the bottom of the body—many sites load JavaScript there to speed up rendering.
If you're trying to extract data, you'll often need to match patterns in the HTML. For instance, if all product prices are in a <span class="price">, you can search for that class.
Frequently Asked Questions
Can I edit a webpage using View Page Source?
No. View Page Source is read-only. To edit a page's HTML or CSS, you need to use DevTools (Inspect) or modify the source file on your server. Changes made in DevTools are temporary and disappear on refresh.
Why does View Source show different content than what I see on the page?
Because the page you see is the result of HTML plus JavaScript and CSS. View Source shows only the initial HTML. Modern websites often use JavaScript to add content after the page loads, so the visible content may not be in the source. Use Inspect to see the final DOM.
How do I save the page source to a file?
In the source tab, right-click anywhere and select "Save As" (or press Ctrl+S). You can save it as an .html file, which you can open later in a text editor or browser. Alternatively, copy the entire code and paste it into a text editor.
Is there a way to view source on mobile Chrome?
Yes, but it's less convenient. You can add view-source: before the URL in the address bar. However, on many mobile sites, the source is heavily minified and hard to read. A better option is to use a third-party app or a desktop browser for serious source inspection.
Does View Page Source show the same code as "curl" or "wget"?
Mostly yes. Both fetch the raw HTML from the server. However, some servers may serve different content based on the User-Agent header (e.g., a mobile version vs. desktop). Chrome's view-source uses your browser's User-Agent, while curl uses its own. So the code can differ slightly.