Dec
3

How to View a Web Page's Source Code

12/03/2026 12:00 AM

How to View a Web Page's Source Code

Every web page is built from code that your browser reads and turns into the page you see. Looking at that code is called viewing the page source. It is a simple way to check how a page is built, find its title and meta tags, or fix a problem on your own site. This guide shows how to view the source code in the most common browsers and what to look for once you open it.

What Is Page Source Code?

The source code of a page is the HTML the server sends to your browser. It contains the text of the page, the headings, the links, and references to images, stylesheets, and scripts. Your browser follows those instructions to display the page.

What you see in the source is only what the browser received. Code that runs on the server, such as PHP, and any data stored in a database are not visible, because they never leave the server.

How to View Page Source in Your Browser

Use the right-click menu

  1. Open the page you want to look at.
  2. Right-click on an empty part of the page.
  3. Choose "View page source" (or "View Page Source").

Use a keyboard shortcut

  • Windows and Linux (Chrome, Edge, Firefox): press Ctrl + U.
  • Mac (Chrome): press Command + Option + U.
  • Mac (Safari): turn on the Develop menu in the settings first, then press Option + Command + U.

Add view-source: to the address

Type view-source: in front of the page address and press Enter. For example:

view-source:https://www.example.com/

This works in most desktop browsers and is handy when the right-click menu is disabled.

Use an online source code tool

If you cannot open the source in your browser, you can use our Get Source Code of Webpage tool. Enter the address of a public page and the tool will fetch its HTML for you.

View Source vs. Inspect Element

These two options look similar but show different things.

  • View page source shows the original HTML exactly as the server sent it.
  • Inspect (developer tools) shows the page as it is now, after JavaScript has run and changed it.

If a page loads content with JavaScript, you may find it in Inspect but not in the page source.

What Can You Find in the Source Code?

The page title and meta description

Look inside the <head> section for the <title> tag and the meta description. These are what search engines often show in results.

Headings

Search for <h1>, <h2>, and <h3> to see how the page is structured.

Canonical and robots tags

A canonical tag tells search engines which address is the main version of a page. A robots meta tag can ask them not to index it.

Links and images

You can see every link and image on the page, and check that images have an alt attribute.

Scripts and stylesheets

The source lists the JavaScript and CSS files the page loads, which can help you spot files that are not needed.

Tips for Reading the Source

  • Press Ctrl + F (or Command + F on Mac) to search for a word such as "title" or "canonical".
  • Turn on line wrap if long lines run off the screen.
  • Focus on the <head> section first, because it holds most of the SEO information.

Using Source Code Responsibly

Viewing the source of a public page is normal and allowed. However, the text, images, and code on a site may be protected by copyright. Learn from how a page is built, but do not copy another site's content or code and publish it as your own.

Frequently Asked Questions

Is it legal to view the source code of a website?

Yes, viewing the HTML your browser receives is a normal part of using the web. Copying and reusing someone else's protected content is a separate matter and may not be allowed.

Can I see the PHP code of a website?

No. PHP and other server-side code run on the server, and only the resulting HTML is sent to your browser.

Why is the right-click menu disabled on some sites?

Some sites block it. You can still use Ctrl + U or the view-source: address.

Can I edit a page by changing its source?

You can change what you see on your own screen using developer tools, but this does not change the real website.