How to See the HTML Code for a Website

By Allen Bethea

The underlying HTML code used to build a website is not hidden but readily accessible to anyone with the proper tools. For example, Web browsers such as Firefox, Chrome, Safari, Opera and Internet Explorer have multiple ways you can view a website's HTML, CSS or JavaScript code directly. In addition, some dedicated Web developer tools can load and open a Web page from the Internet like a file stored on a local disk.

View Source in Browser

The steps required to see a website's HTML code are essentially the same for Firefox, Chrome, Safari, Opera and Internet Explorer. Right-click a section of a Web page that contains only text and then select the "View Source" or "View page source" option. Depending on your browser setup, the HTML code opens in a new browser tab or in a separate application window.

Save Source Code to Disk

If you need to examine or edit a website's code later, you can save the page to your hard drive. When you right-click a Web page in Firefox or Safari, you are offered the option to "Save Page As." Chrome and Opera have the "Save as" option. To save a Web page using Internet Explorer, click "Tools," "File," and then "Save as." In addition to the Web page itself, the browser saves all the images, CSS files and JavaScript the page uses that are stored locally on its Web server.

Built-in Browser Developer Tools

Firefox, Chrome, Opera and Internet Explorer each provide a developer mode that enables you to simultaneously view a rendered Web page and its HTML, CSS and JavaScript code. If you click an element on the Web, its code appears in the developer display panel. The developer panel can be accessed through the options or configuration tool. While Safari does not have a native developer tool, you can install one as an extension.

Web Developer Applications

Website design tools like Dreamweaver, Kompozer and Microsoft Expressions enable you to open an online Web page using its URL. You view the HTML code in a source code-only view or a split, preview and source view. In addition, you can edit the code and view the changes in real time. The actual code stored on the website's server is never changed.

Issues You May Encounter

Intentionally or unintentionally, some websites do not give up their HTML code easily. For example, some sites use JavaScript code, which blocks right-clicks. You can still view the source code by downloading the page to your disk or by disabling JavaScript in your browser. Other sites use HTML frames or iframes, which prevent you from directly accessing their source. Firefox, Chrome, Safari and Opera detect frame-based websites and automatically offer you an option to view a frame's source code. If a Web page uses a JavaScript or CSS file stored on another domain, you can view that file's code directly by copying its URL from the HTML code you can access and then pasting it into the address bar of a new browser tab.