How to run a HTML file in Chrome

By default, the Chrome web browser is configured with security features, which render it incapable of opening the Doc/Index.html file. In order to open the Doc/Index.html file in Chrome, configuration changes must be made.

Steps

  1. In Windows, go to Start > All Programs > Accessories > Run.

    The path to the Run dialog box may be different depending on the version of Windows used.

    The Run dialog box opens.

  2. In the Run dialog box, click Browse.

    The Browse dialog box opens.

  3. In the Browse dialog box, navigate to the Google directory, select the Chrome application and then click Open.

    The Run dialog box updates to include the path to Chrome.

    How to run a HTML file in Chrome

  4. In the Run dialog box, add the following to the end of the path to Chrome (after the quotation mark):--allow-file-access-from-files— or —--disable-web-security
  5. Click OK.

    Chrome starts and is now able to open the Doc/Index.html file. Changes are not saved when you close Chrome.

Whether you’re a web designer debugging your site’s source code or just curious about what a site’s code looks like, you can view the HTML source right in Google Chrome. There are two ways to view the HTML source: View Source and Inspect using Developer Tools.

View Source Using View Page Source

Fire up Chrome and jump to the webpage you want to view the HTML source code. Right-click the page and click on “View Page Source,” or press Ctrl + U, to see the page’s source in a new tab.

How to run a HTML file in Chrome

A new tab opens along with all the HTML for the webpage, completely expanded and unformatted.

How to run a HTML file in Chrome

If you’re looking for a specific element or part in the HTML source, using View Source is tedious and cumbersome, especially if the page uses a lot of JavaScript and CSS.

Inspect Source Using Developer Tools

This method uses the Developer Tools pane in Chrome and is a much cleaner approach to view the source code. HTML is easier to read here thanks to the additional formatting and the ability to collapse elements you aren’t interested in seeing.

Open Chrome and head to the page you want to inspect; then press Ctrl + Shift + i. A docked pane will open alongside the webpage you’re viewing.

How to run a HTML file in Chrome

Click on the little gray arrow next to an element to expand it even further.

How to run a HTML file in Chrome

If you don’t want to see the full page’s code by default, but instead inspect a specific element in the HTML, right-click that space on the page, then click “Inspect.”

How to run a HTML file in Chrome

When the pane opens this time, it goes directly to the portion of code that contains that element you clicked.

How to run a HTML file in Chrome

If you want to change the dock position, you can move it to the bottom, left, right, or even undock it into a separate window. Click the menu icon (three dots), then choose either undock into a separate window, dock to the left, dock to the bottom, or dock to the right, respectively.

How to run a HTML file in Chrome


That’s all there is to it. When you finish looking at the code, either close the View Source tab or click the ‘X’ in the Developer Tools pane to return to your webpage.

Even though HTML pages appear on the Web, you do not have to connect to the Web to view them. If you are developing Web pages for your business site, you will perform that task faster by previewing them pages locally in your browser before uploading them to your Web server. You may also need to view HTML files that you download from the Internet or receive through the email. Because all browsers allow you to run HTML files from your hard drive, you can launch them instantly, right from your desktop.

  1. 1.

    Press "Windows-E" to launch Windows Explorer.

  2. 2.

    Navigate to the folder that contains your HTML file.

  3. 3.

    Double-click the file. Your default browser displays the HTML document. If the browser is not open, Windows launches it.

References

Resources

  • HTML Dog: Tutorial

Tips

  • If you make a change to an HTML file after viewing it in a browser, press “Ctrl-F5” in your browser to refresh the browser’s view of the document. Otherwise, the document might not show the changes you just made.
  • You can also press "Ctrl-O" in your browser to open a file selection window. Navigate to the HTML file you wish to open and double-click it to you that file in your browser.
  • Internet Explorer becomes your default browser when you install Windows. It will launch when you double-click an HTML file. However, you may prefer to run an HTML file in a specific browser -- for example, Firefox may contain debugging or design tools that you use during development. You can make an HTML file open in a different browser by right-clicking the file in Windows Explorer and selecting "Open With." Select the browser you would like to use from the list that appears in the drop-down menu.
  • If you use a full-featured HTML editor to develop Web pages, your editor may have a button or menu that allows you to preview an HTML page in the editor or in your browser.

Writer Bio

After majoring in physics, Kevin Lee began writing professionally in 1989 when, as a software developer, he also created technical articles for the Johnson Space Center. Today this urban Texas cowboy continues to crank out high-quality software as well as non-technical articles covering a multitude of diverse topics ranging from gaming to current affairs.

How can I run my HTML code on Chrome?

Google Chrome.
Click the menu icon. on the browser toolbar..
Select More tools, then View Source..

How do I run an HTML file in my browser?

Open the saved HTML file in your favorite browser (double click on the file, or right-click - and choose "Open with").

How do I run a HTML code?

How to open html file in chrome. To Open or Run an HTML file in Chrome Browser we need to Double click on that HTML file. It will Automatically will open in your Web Browser. If you file Isn't opening in your Browser, Then Right click on that HTML file and Select Open with option from there.

Why is HTML file not opening in Chrome?

Open a new tab in Chrome, then press Ctrl (Windows) or Cmd (Mac) + O. It will bring up the same Open File menu. Find your HTML file and open it. If the shortcut didn't work, it might be that your browser has a different set of hotkeys for this command.