How to View the Source Code of a Web Page

View a web page's source code to diagnose errors

What to Know

  • On most major browsers, you can access a site's source code by pressing Ctrl+U in Windows.
  • On a Mac, press Cmd+Option+U within most major browsers or Cmd+U in Firefox.
  • On Android, use the view-source: URL tweak to view source code. On Safari for iOS, this isn't supported.

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 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.

How to View Source in a Desktop Browser

For all the major desktop browsersGoogle 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.

website source code

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:https://www.lifewire.com to view the source code behind Lifewire'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.

Was this page helpful?