How to View the Source Code of a Web Page 2021


Although web browsers interpret the Hypertext Markup Language files and Cascading Style Sheets that make the web appear as it does, a hotkey or URL tweak forces browsers to display not the rendered webpage, but the source code of that page, in a new tab or window. Although most people rarely need to examine the source code, developers use this perspective to troubleshoot layout inconsistencies or to fix bugs on a website.

Getty Images (Logovski #465458409)

How to View Source in a Desktop Browser

For all the major desktop browsers—Google Chrome, Microsoft Edge, Mozilla Firefox, Opera, Vivaldi—press Ctrl+U to open a new tab that displays the raw HTML of the page you're on. On a Mac, press Cmd+Option+U or Cmd+U in Firefox.

Steps for viewing a website's source code in Google Chrome

Alternatively, all desktop browsers support a URL-specific tweak. Prepend the text view-source: to the URL to open the page in Source mode. For example, type view-source: to view the source code behind Ach5's main landing page.

Prefer a mouse, or need to tweak the HTML on the fly? All the main browsers support a View Source command somewhere within its menu structure, and they also support a developer mode (named various things, and launched various ways) that permits real-time tweaking to how a page executes based on changes you make in the developer interface.

How to View Source on a Default Mobile Browser

The stock Android browser allows the view-source: URL tweak. On iOS, however, the stock Safari app does not support this feature. On Apple's platform, you'll need to launch a different browser or a source-code viewing app from the App Store.

Individual mobile browsers that you installed from your platform's app store behave differently. Consult the browser's documentation for specific procedures.