How to View Page Source in Chrome

3 min read

Introduction

Viewing the page source in Chrome is a crucial skill for web developers, designers, and curious users interested in understanding how a webpage is constructed. Whether you’re looking to view the HTML code of a site, troubleshoot a webpage, or learn more about web development, knowing how to access the Chrome page source is essential. This guide will walk you through various methods to view the source code in Chrome across different platforms.

Quick Fixes to Try First

  • Use the keyboard shortcut: Windows/Linux: Ctrl + U; Mac: Cmd + Option + U
  • Right-click on the page and select View Page Source
  • Check Chrome settings if shortcuts are not working: Settings > Privacy and Security > Site Settings
  • Clear your browser cache: Settings > Privacy and Security > Clear Browsing Data

View Source in Chrome on Windows, macOS, and Linux

View Source Shortcut

The quickest way to view the HTML source code in Chrome is through keyboard shortcuts:

  1. Windows/Linux: Press Ctrl + U on your keyboard.
  2. Mac: Press Cmd + Option + U on your keyboard.

This will open a new tab displaying the page’s HTML code.

View Source via Right-Click Menu

If you prefer using the mouse, follow these steps:

  1. Right-click anywhere on the webpage.
  2. Select View Page Source from the context menu.

This action will open a new tab with the page’s source code.

Using DevTools to View Source

Chrome’s Developer Tools (DevTools) provide a more in-depth look at a webpage’s source code:

  1. Open DevTools by pressing F12 or Ctrl + Shift + I (Windows/Linux), or Cmd + Option + I (Mac).
  2. Navigate to the Elements tab to view the HTML structure.

Search Within Source Code

To find specific elements or text within the source code:

  1. Open the page source using any method above.
  2. Press Ctrl + F (Windows/Linux) or Cmd + F (Mac) to open the search bar.
  3. Enter your search query to locate specific code or text.

Save Source Code

If you need to save the page source for offline viewing or analysis:

  1. Open the page source in a new tab.
  2. Right-click and select Save As.
  3. Choose a location on your computer and click Save.

Viewing Source on Android and iOS

Android

To view the page source on an Android device:

  1. Open Chrome and navigate to the desired webpage.
  2. Enter view-source: before the URL in the address bar (e.g., view-source:https://www.example.com).
  3. Press Enter to view the source code.

iOS

Unfortunately, iOS does not support viewing source code directly in the Chrome app. However, you can use third-party apps or extensions available in the App Store to access this feature.

Conclusion

Understanding how to view page source in Chrome can enhance your web browsing experience, whether you’re debugging a webpage or learning more about web development. By following the steps outlined in this guide, you can access and utilize the Chrome page source across various platforms. Remember to use keyboard shortcuts for quick access and explore DevTools for a comprehensive view of the webpage structure.