Why is my HTML file not displaying to the browser?

24,578

Solution 1

It loaded on Fire Fox, just not on Google Chrome for some reason. I'm sorry for wasting everyone's time. As I have said, I am unfamiliar with VS Code. Thank you for all of your suggestions.

Solution 2

Are you sure? It does display on mine. Is the file saved as a .html file? Also, try opening it on another browser. If that doesn't work, try creating a new file in Notepad or something similar, save it with a .html file extension and try opening it again.

EDIT: Try using Notepad. Check if the file is saved with a UTF-8 encoding.enter image description here If that doesn't work, try installing another browser or using Edge/Safari/Internet Explorer or whatever built-in browser you have.

Solution 3

In case someone is still struggling with this, try saving your files before you open them. That fixed the problem for me.

Share:
24,578
mplungjan
Author by

mplungjan

In IT since 1986 and have been answering questions since 1997 on various sites including the hyphened one. In the time I have been here, I have enjoyed gaining enough rep to help edit question and would be happy to give more assistance since that is what I like to do in general, help people.

Updated on July 09, 2022

Comments

  • mplungjan
    mplungjan almost 2 years

    I am learning how to use a text editor, and I've just created my first file with it. It previews with the correct output, but when I run it in the browser, it gives me a blank page.

    As you can see, the doctype and html tags are in place, as well as the head and body. I am using Visual Studio Code as my text editor. Why will this not display anything in my browser? To be clear, it does preview, just won't display in browser

    <!DOCTYPE html>
    <html>
    <head>
      <title>Hello World</title>
    </head>
    <body>
      <h1>Hello World</h1>
    </body>
    </html>

    • mplungjan
      mplungjan over 3 years
      Do you save the file with extension .html and open it using the browser or are you trying to get VSC to display it? As you can see it shows in the snippet I made you
    • Quentin
      Quentin over 3 years
      How are you trying to run it in the browser? Are you typing the URL manually? Are you using VS code to open the browser and send it the URL? Are you double clicking the file in your file manager? Where are you loading the HTML document from? A web server? A local file? The live server plugin for VS Code? Have you tried refreshing the page in the browser? Clearing the cache? Using a different browser?
    • Admin
      Admin over 3 years
      I created the file as index.html in VS Code, then went to my file explorer and selected to open in Google Chrome. I originally opened it in Fire Fox, but that browser doesn't load well on my computer (I have a windows 7). I selected Google Chrome as my default, and the file is now classified on my computer as a Chrome HTML Document. Refreshing the page was the first thing I tried. If it changes anything, the browser showed a dark screen with all of my bookmarks/tabs at the top. I know this is a simple question, but I am unfamiliar with the software and just looking for a little help.
    • Arca Ege Cengiz
      Arca Ege Cengiz over 3 years
      If all this doesn't work try it on another computer.
  • Quentin
    Quentin over 3 years
    That won't make any difference.
  • Quentin
    Quentin over 3 years
    The HTML 5 Doctype is a magic string that triggers Standards Mode in browsers. The <html> start tag starts the HTML element. They are not the same thing. (Historically the html in the Doctype declaration would state what the name of the root element was).
  • Quentin
    Quentin over 3 years
    How would that help? They've got a basic HTML 5 structure already.
  • Admin
    Admin over 3 years
    It is saved as index.html. I have been using google chrome. I can try to use Fire Fox, but that browser doesn't load well on my computer.
  • Arca Ege Cengiz
    Arca Ege Cengiz about 3 years
    can you then please accept an answer that worked so that it's easier for others to find the correct answer?
  • Arca Ege Cengiz
    Arca Ege Cengiz about 3 years
    Also, maybe Google Chrome doesn't have read access to the html file