This page was last modified on 11 October 2014, at 17:17. This page has been accessed 2,404 times. Content is available under Public Domain unless otherwise noted.
Source code is the list of human-readable instructions that a programmer writes—often in a word processing program—when he is developing a program. The source code is run through a compiler to turn it into machine code, also called object code, that a computer can understand and execute. Object code consists primarily of 1s and 0s, so it isn't human-readable.
Source Code Example
Source code and object code are the before and after states of a computer program that is compiled. Programming languages that compile their code include C, C++, Delphi, Swift, Fortran, Haskell, Pascal and many others. Here is an example of C language source code:
You don't have to be a computer programmer to tell that this code has something to do with printing 'Hello World.' Of course, most source code is much more complex than this example. It is not unusual for software programs to have millions of lines of code. Windows 10 operating system is reported to have about 50 million lines of code.
Source Code Licensing
Source code can be either proprietary or open. Many companies closely guard their source code. Users can use the compiled code, but they cannot see or modify it. Microsoft Office is an example of proprietary source code. Other companies post their code on the internet where it is free to anyone to download. Apache OpenOffice is an example of open source software code.
Interpreted Program Languages Code
Some programming languages such as JavaScript are not compiled into machine code but are interpreted instead. In these cases, the distinction between source code and object code does not apply because there is only one code. That single code is the source code, and it can be read and copied. In some cases, developers of this code may intentionally encrypt it to prevent viewing. Programming languages that are interpreted include Python, Java, Ruby, Perl, PHP, Postscript, VBScript and many others.
All Internet browsers allow users to view the HTML source code of any of web page they visit. The following sections contain information on the multiple ways to view the source code in each of the major browsers. To proceed, choose an entry from the list below and follow the instructions for that section.
Introductory information
When viewing the source code of a web page, it is important that you keep in mind that information and code not processed by the server won't appear. For example, almost all Internet search engines process information on a server, and then display 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, features, such as search engines, forums, polls, chat, etcetera, will not display their code. Copying the information from the source code may cause errors or direct you back to the page from which you copied the information.
Microsoft Edge users
To view the source code of a web page in Microsoft Edge, follow the steps below.
- Press Ctrl+U or F12 on your computer's keyboard.
- Select the Elements tab at the top of the right window.
Or
- Right-click on a blank part of the web page and select View source from the pop-up menu that appears.
Or
- Open Microsoft Edge and navigate to the web page of your choice.
- Click the More icon in the upper-right corner of the screen.
- Select Developer Tools from the drop-down menu that appears.
- Select the Elements tab at the top of the right window.
In Microsoft Edge, the DOM tool also provides interaction with the source code and CSS settings, allowing users to see how changes in the code affect the web page immediately.
Microsoft Internet Explorer users
To view the source code of a web page in Microsoft Internet Explorer, follow the steps below.
- Press Ctrl+U or F12 on your computer's keyboard.
- Click the Debugger tab at the top of the new menu.
Or
- Right-click on a blank part of the web page and select View source from the pop-up menu that appears.
Or
- Open Internet Explorer and navigate to the web page of your choice.
- Press the Alt key to bring up the browser's menu bar.
- Select View, and then Source from the drop-down menu that appears.
- Click the Debugger tab at the top of the new menu.
With the latest versions of Internet Explorer, pressing the F12 key brings up the DOM 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 and Netscape users
To view the source code of a web page in Mozilla Firefox, follow the steps below.
- Press Ctrl+U on your computer's keyboard.
Or
- Right-click on a blank part of the web page and select View Page Source from the pop-up menu that appears.
Or
- Open Mozilla Firefox and navigate to the web page of your choice.
- Press the Alt key to bring up the browser's menu bar.
- Select Tools, Web Developer, and then Page Source.
With the latest versions of Firefox, pressing the F12 key or Ctrl+Shift+I 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.
View a section of the page's source code
- Highlight the portion of a web page for which you'd like to view the source code.
- Right-click that highlighted section, and then click View Selection Source.
Use the Firebug add-on to not only view the source code of a page but change and view those changes live through the browser.
Google Chrome users
To view the source code of a web page in Google Chrome, follow the steps below.
- Press Ctrl+U on your computer's keyboard.
Or
- Right-click on a blank part of the web page and select View page source from the pop-up menu that appears.
Or
- Open Chrome and navigate the web page of your choice.
- Click on Customize and control Google Chrome icon in the upper-right side of the browser window.
- From the drop-down menu that appears, select More tools and then Developer tools.
- Click the Elements tab at the top of the new section that appears.
With the latest versions of Chrome, pressing the F12 key 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.
Apple Safari users
To view the source code of a web page in Apple Safari, follow the steps below.
- Press Command + Option + U on your keyboard.
Or
- Right-click on a blank part of the web page and select Show page source from the pop-up menu that appears.
Or
- Open the Safari browser and navigate to the web page of your choice.
- Select the Develop menu.
- Choose the Show page source option.
Opera users
To view the source code of a web page in Opera, follow the steps below.
- Press Ctrl+U on your keyboard.
Or
- Right-click on a blank part of the web page and select Page source from the pop-up menu that appears.
Or
- Open Opera and navigate to the web page of your choice.
- Click the Menu button in the upper-left corner of the browser window.
- In the Developer sub-menu, choose Page source.
If you don't see the Developer sub-menu, choose More tools → Show developer menu. Then, click the menu button again. You should now see the Developer sub-menu listed.
TipWith the latest versions of Opera, pressing the shortcut combination Ctrl+Shift+I 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.
Android phone running Chrome
- Open the Google Chrome Internet browser on your phone.
- Open the web page whose source code you'd like to view.
- Tap once in the address bar and then move the cursor to the front of the URL.
- Type view-source: and press Enter or Go.
For example, to view the code for our homepage, you would type view-source:https://www.computerhope.com
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 you've used to open it.
- If you've used the Ctrl+U method (except for Edge) or the right-click method, close the new tab that opened in the top of your browser window.
- If you've used the developer method (pressing F12 or Ctrl+Shift+I), click the icon in the upper-right corner of the tools window.
Additional information
- See our HTML validator and source code definition for further information.