Why is my HTML file not displaying to the browser?

Viewed 30272

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>

7 Answers

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.

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

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.

I had this same baffling problem. I quit Chrome, re-opened, and then I was able to open my .html files (from my Mac's Finder) with Chrome just like I could already open them with Safari or other browsers.

Possible Reasons:

  • You might not have saved the changes after writing the code (most likely).
  • Problem with the browser (load it in another browser)
  • Check the extension (just for clarification)

There is no problem with !DOCTYPE html tag or html tag.

In visual studio code just type in a blank page

html:5

then just press the touch "tab", it will display a basic html 5 structure to start

Just remove "<html>" a the second line it's already set in the first line

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