How to Capture Page Source in Firefox Chrome Edge Safari
In this article
Capturing a webpage's source code allows you to view the underlying HTML, CSS, and JavaScript that make up the page. This is useful for web developers, students, or anyone troubleshooting website behavior. The page source reveals structural details not visible in the rendered page and helps diagnose layout issues, inspect metadata, or analyze SEO elements. All major browsers—Firefox, Chrome, Edge, and Safari—provide built-in tools to access this information quickly. While the exact menu labels may vary slightly by version, the core methods remain consistent across platforms.
What You'll Need
- A computer running Windows, macOS, or Linux
- One of the following browsers: Mozilla Firefox, Google Chrome, Microsoft Edge, or Apple Safari
- Internet access to load the webpage you want to inspect
- Basic familiarity with navigating browser menus and keyboard shortcuts
Step-by-Step
- Open your preferred browser (Firefox, Chrome, Edge, or Safari) and navigate to the webpage whose source you want to capture.
- In Firefox: Press Ctrl+U (Windows/Linux) or Cmd+Option+U (Mac). Alternatively, right-click anywhere on the page and select "View Page Source" from the context menu.
- In Chrome: Press Ctrl+U (Windows/Linux) or Cmd+Option+U (Mac). Or right-click and choose "View Page Source" from the menu.
- In Microsoft Edge: Press Ctrl+U (Windows) or Cmd+Option+U (Mac). You can also right-click and select "View Page Source".
- In Safari: First, enable the Develop menu. Go to Safari → Settings (or Preferences) → Advanced, then check "Show Develop menu in menu bar." After enabling, go to the menu bar and click Develop → Show Page Source. Alternatively, press Cmd+Option+U once the Develop menu is active.
- Once opened, the page source appears in a new tab or window, typically in plain text format with syntax highlighting in Chrome, Edge, and Firefox.
- To save the source code, press Ctrl+S (Windows) or Cmd+S (Mac) while the source tab is active. Choose a location and save it as a .html file for later use.
- For more advanced inspection (such as viewing dynamic content or elements that change after loading), use Developer Tools instead. Press F12 or Ctrl+Shift+I (Cmd+Option+I on Mac) to open the full inspector, then navigate to the Elements or Sources tab.
- Close the source tab when finished to avoid cluttering your browser session.
Common Mistakes
One frequent error is confusing "View Page Source" with the Developer Tools inspector. The former shows only the original HTML sent by the server, while the latter reflects live DOM changes made by JavaScript. Users expecting to see dynamically loaded content (like comments or images loaded via AJAX) may be misled if they only check the static source.
Another mistake is trying to use Safari’s page source shortcut before enabling the Develop menu. Without this step, the keyboard shortcut and menu option remain unavailable. Users often overlook this requirement, leading to confusion when commands don’t work.
Some users right-click on interactive elements like videos or menus and expect to see relevant code directly, but the source view shows the entire page’s HTML, not just the element under the cursor. To inspect specific parts, use Developer Tools instead.
Forgetting to save the source before closing the tab is another oversight. Since the source is temporary, not saving it means repeating the process later.
Tips
Use Ctrl+F (Cmd+F on Mac) in the source window to search for specific elements, such as meta tags, script references, or IDs. This speeds up navigation in long pages.
In Chrome and Edge, the "View Page Source" window highlights syntax in color, making it easier to distinguish tags, attributes, and text. Firefox also provides similar readability improvements.
If you're debugging responsive design, capture the source after resizing the browser window to simulate different devices. However, remember that the source itself doesn’t change—only the rendered layout does.
For pages that rely heavily on JavaScript, consider using the Developer Tools’ "Elements" tab instead. It shows the current state of the DOM, including modifications made after page load.
When sharing source code with others, save it as a .html file and include a brief note about when and how it was captured, especially if dynamic content is involved.
Troubleshooting
If pressing Ctrl+U does nothing in Safari, confirm that the Develop menu is enabled. Go to Safari → Settings → Advanced and ensure "Show Develop menu in menu bar" is checked. Without this, shortcuts won’t work.
If the source tab fails to open, try right-clicking and selecting "View Page Source" instead. Some browser extensions or security settings may block keyboard shortcuts.
When viewing the source of a single-page application (SPA), you may see minimal HTML content because most content is loaded dynamically. In such cases, use Developer Tools and check the "Elements" tab for the full rendered structure.
If the source appears garbled or in a different encoding, check your browser’s encoding settings. In Firefox, go to View → Text Encoding and select UTF-8. Chrome and Edge typically handle encoding automatically.
If saving the source fails, ensure you have write permissions to the selected folder. Try saving to the desktop first to rule out directory restrictions.
Frequently Asked Questions
Does View Page Source show JavaScript-generated content?
No, it only shows the original HTML from the server. For JavaScript-modified content, use Developer Tools’ Elements tab.
Can I view source on mobile browsers?
Not directly through standard taps. Mobile browsers lack built-in source viewing. Use desktop versions or remote debugging tools instead.
Is the page source the same in all browsers?
Yes, the source code delivered by the server is identical. Differences arise only in how browsers render or modify it afterward.
Why can’t I find certain elements in the source?
They may be added by JavaScript after loading. Check the Developer Tools instead of relying solely on View Page Source.
Does capturing page source violate copyright?
No, viewing source is allowed under fair use for learning or debugging. However, republishing or using code without permission may infringe copyright.
Can I edit the page source in the browser?
You can edit it temporarily in Developer Tools, but changes are local and lost on refresh. The original source remains unchanged on the server.