How to get html code from website

HyperText Markup Language is a language used to create pages on the Web. Web browsers interpret the language and display the page as instructed by the HTML. By viewing the page’s HTML or source code, you can see how elements on the page are handled as well as paths to the page’s images or audio features. For a small business, viewing the source code of a page that has an element you wish to incorporate on your own page or even viewing elements on your own page can be helpful in determining how the browser interprets the HTML.

  1. Open your browser and navigate to the page for which you wish to view the HTML

  2. Right-click on the page to open the right-click menu after the page finishes loading.

  3. Click the menu item that allows you to view the source. In Internet Explorere, the menu item is “View Source.” In Mozilla Firefox and Chrome, the menu item is “View Page Source.” In Opera, the menu item is “Source.”

  4. When the source page opens, you'll see the HTML code for the full page. Scan through it to locate code for specific features and objects on the page, as desired.

Updated: 02/01/2021 by

How to get html code from website

Every major Internet browser allows users to view any web page's HTML source code. The following sections contain information on the multiple ways to view the source code in each major browser. To proceed, choose an entry from the list below and follow the instructions.

Introductory information

When viewing the source code of a web page, the information and code processed by the server won't appear. For example, a search engine processes information on a server and then displays the results on a web page. In other words, you can view the code that makes up the results page, but you cannot view the search engine's source code.

This rule applies to all server-side scripts, SSI, and programming code. Therefore, you cannot view a script's source code used in search engines, forums, polls, chat, etc. Also, copying the information from the source code may cause errors or direct you back to the page from which you copied the information.

Google Chrome

How to get html code from website

To view the source code of a web page in Google Chrome, use any of the following methods.

View source code only

Method one

To view only the source code, press the shortcut keys Ctrl+U on your computer's keyboard.

Method two

Right-click a blank part of the web page and select View page source from the pop-up menu that appears.

How to get html code from website

View page source with elements

  1. Open Chrome and navigate the web page whose source code you'd like to view.
  2. Click the Customize and control Google Chrome
    How to get html code from website
    icon in the upper-right corner of the browser window.
  3. From the drop-down menu that appears, select More tools, then select Developer tools.
  4. Click the Elements tab in the top-left corner of the new section that appears at the bottom of the screen.

How to get html code from website

Tip

In Chrome, pressing F12 or Ctrl+Shift+I also brings up the interactive developer tool. This tool provides much more interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page immediately.

Mozilla Firefox

How to get html code from website

To view the source code of a web page in Mozilla Firefox, use any of the following methods.

View source code only

Method one

To view only the source code, press Ctrl+U on your computer's keyboard.

Method two

Right-click a blank part of the web page and select View Page Source from the pop-up menu that appears.

How to get html code from website

View page source with elements

  1. Open Firefox and navigate to the web page whose source code you want to view.
  2. Click the Menu
    How to get html code from website
    icon in the top-right corner of the screen.
  3. Select More tools in the drop-down menu, then select Web Developer Tools from the expanded menu.
  4. Click the Inspector tab in the top-left corner of the section that appears at the bottom of the screen.

How to get html code from website

Tip

In Firefox, pressing F12 or Ctrl+Shift+I also brings up the interactive developer tool. This tool provides interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page in real-time.

View a section of the page's source code

  1. Highlight the portion of a web page where you want to view the source code.
  2. Right-click that highlighted section and select View Selection Source.

Tip

You can use the Firebug add-on to view and edit a page's source code, and view the changes live through the browser.

Microsoft Edge

How to get html code from website

To view the source code of a web page in Microsoft Edge, use any of the following methods.

View source code only

Method one

To view only the source code, press Ctrl+U on your computer's keyboard.

Method two

Right-click a blank part of the web page and select View page source from the pop-up menu that appears.

How to get html code from website

View page source with elements

  1. Open Microsoft Edge and navigate to the web page whose source code you want to view.
  2. Click the Settings and more
    How to get html code from website
    icon in the upper-right corner of the screen.
  3. Move your mouse over More tools in the drop-down menu, and select Developer tools from the expanded menu.
  4. Click the Elements tab at the top of the window that appears on the right side of the screen.

How to get html code from website

Tip

In Microsoft Edge, pressing F12 or Ctrl+Shift+I also brings up the interactive developer tool. This tool provides interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page in real-time.

Microsoft Internet Explorer

How to get html code from website

To view the source code of a web page in Microsoft Internet Explorer, use any of the following methods.

View source code only

Method one

To view only the source code, press Ctrl+U on your computer's keyboard.

Method two

Right-click a blank part of the web page and select View source from the pop-up menu that appears.

How to get html code from website

View page source with elements

  1. Open Internet Explorer and navigate to the web page whose source code you want to view.
  2. Click Tools
    How to get html code from website
    in the upper-right corner.
  3. Select F12 Developer Tools from the drop-down menu.
  1. Click the DOM Explorer tab at the top-left corner of the developer tools menu.

How to get html code from website

Tip

In Internet Explorer, pressing F12 brings up the DOM tool. This tool provides interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page immediately.

Safari

How to get html code from website

In Safari, viewing a webpage's source code requires enabling the developer options. The following sections show you how to turn on this feature and then how to view the source code of a web page.

Accessing developer options in Safari

  1. Open the Safari browser.
  2. Select
    How to get html code from website
    from the menu bar at the top-left corner of the screen.
  3. In the drop-down menu that appears, select Preferences.

How to get html code from website

  1. Click the Advanced tab, and check the box next to the Show Develop menu in menu bar.

How to get html code from website

  1. You should now see the Develop selector in the Apple menu bar at the top of the screen.

How to get html code from website

Viewing the source code

Note

You must have the developer options enabled for the following steps to work.

Method one

  1. Open Safari and navigate to the web page whose source code you want to view.
  2. In the Apple menu bar at the top of the screen, click the Develop selector and choose Show Page Source from the drop-down menu.
  3. In the center of the screen, click the Elements tab at the top of the developer tools section.

How to get html code from website

Method 2

Right-click a blank part of the web page and select Show Page Source from the pop-up menu that appears.

How to get html code from website

Tip

Once the developer options are enabled, you can also press Command+option+U to view the source code.

Opera

How to get html code from website

To view the source code of a web page in Opera, use any of the following methods.

View source code only

Method one

To view only the source code, press Ctrl+U on your computer's keyboard.

Method two

Right-click a blank part of the web page and select Page source from the pop-up menu that appears.

How to get html code from website

View page source with elements

  1. Open Opera and navigate to the web page whose source code you want to view.
  2. Click the Opera
    How to get html code from website
    icon in the upper-left corner of the browser window.
  3. Move your mouse over Developer in the drop-down menu and select Developer tools from the expanded menu.
  4. Click the Elements tab at the top of the window that appears on the right side of the screen.

How to get html code from website

Tip

If you don't see the Developer submenu, select More toolsShow developer menu. Then, click the menu button

How to get html code from website
again. You should now see the Developer entry listed.

Tip

In Opera, pressing Ctrl+Shift+I also brings up the interactive developer tool. This tool provides interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page in real-time.

Android phone or tablet using Chrome

How to get html code from website
  1. Open the Google Chrome browser on your Android phone or tablet.
  2. Open the web page whose source code you want to view.
  3. Tap once in the address bar and move the cursor to the front of the URL.
  4. Type view-source: and tap Enter or Go.

Tip

For example, to view the code for our homepage, you would type view-source:https://www.computerhope.com.

If the steps above don't work on your Android phone, use the method on the iPhone or iPad using Safari section. The same code works on Android phones. The only differences are using Chrome instead of Safari and how a bookmark is created.

  • How to create an Internet favorite or bookmark.
  • How to delete and organize Internet favorites and bookmarks.

Tip

If you find it difficult to navigate the source code on your mobile device using the method above, you may also want to consider an online tool.

How to get html code from website

iPhone or iPad using Safari

Viewing the source code of a web page on an iPhone or iPad takes a bit more work, but it is possible. The process requires you to create a bookmark, assign JavaScript code to it, and use the bookmark on a web page to view its source code.

Note

If you'd prefer to use an app to view a web page's source code, you can download the free View Source app from the iOS App Store.

Create a bookmark to view source code

  1. Open the Safari browser on your iPhone or iPad.
  2. Access any web page, such as www.computerhope.com.
  3. Tap the More icon at the bottom of the screen.

How to get html code from website

Tip

You can also press and hold your finger on the Bookmark icon at the bottom of the screen until a menu appears.

  1. In the menu that opens, tap the Add Bookmark option.

How to get html code from website

  1. Tap the bookmark name field, tap the x on the right side to clear the current name, and enter "View web page source code" as the new name.

How to get html code from website

  1. Tap Save in the top-right corner to save the bookmark.
  2. Copy the entire JavaScript code snippet below.
javascript:(function(){var a=window.open('about:blank').document;a.write('Source code of '+location.href);a.close();var b=a.body.appendChild(a.createElement('pre'));b.style.overflow='auto';b.style.whiteSpace='pre-wrap';b.appendChild(a.createTextNode(document.documentElement.innerHTML))})();
  1. In Safari, access the bookmarks by tapping the bookmarks icon at the bottom of the screen.

How to get html code from website

  1. Find the bookmark you created above, then press and hold your finger on the bookmark until a menu opens at the bottom of the screen.
  2. Tap the Edit option on the menu.

How to get html code from website

  1. On the Edit Bookmark screen, tap the URL, tap the x to clear the URL, and paste the JavaScript code from step 7 into the URL field.

How to get html code from website

  1. Tap Done at the bottom-right of the screen to save the bookmark changes.

Use a bookmark to view source code

After you've created the bookmark above, you can now view the source code for a web page.

  1. In Safari, access the web page where you want to view the source code.
  2. Tap the bookmarks icon at the bottom of the screen.

How to get html code from website

  1. Tap the View web page source code bookmark you created.

How to get html code from website

A new Safari browsing tab opens, displaying the source code for the web page.

How to get html code from website

Tip

If you have difficulties navigating the source code on your mobile device using the above method, you may also consider using an online tool.

How to close the source code page or tool

Once you're done viewing the source code on a web page, you may want to exit or close it. Closing the source code depends on the method used to open it.

  • If you've used the Ctrl+U method (except Edge) or the right-click method, close the new tab that opened at the top of your browser window.
  • If you've used the developer method (using F12 or Ctrl+Shift+I), press those same keys again, or click the
    How to get html code from website
    icon in the upper-right corner of the tools window.

Use an online tool to view the source code

In addition to using a browser, several online tools allow you to view the source code of any web page. These tools may be helpful because most can format, stylize, and highlight the code to make it easier to read. Below is a short list of some of these tools:

  • View page source
  • Code Beautify source code viewer
  • HTML Viewer

How do I extract the HTML code from a website?

Right-click a blank part of the web page and select Show Page Source from the pop-up menu that appears. Once the developer options are enabled, you can also press Command + option + U to view the source code.

How can I get HTML and CSS code from a website?

Go to the outer edge of a site (e.g. far left), then right-click and click on “View Page Source” (or the option that's similarly named). That will bring up all the HTML code, along with links to CSS files, Javascript, images, etc. You can now read through it and see what that page is created with.

How do I view the HTML code of a website in Chrome?

Navigate to the web page you would like to examine. Right-click the page and look at the menu that appears. From that menu, click View page source. The source code for that page will now appear as a new tab in the browser.