user1767774
user1767774

Reputation: 1825

when opening an html file on browser, I see the source code

I am trying to open a basic "hello world" html file on a browser (chrome/explorer). However, the browser displays the code itself rather than the expected result. What can be the problem?

The code:

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

I've just written this code in a text file called helloWorld.html and opened it with the browser. Thanks!

Upvotes: 1

Views: 3900

Answers (2)

drbswa
drbswa

Reputation: 51

If you are using a text editor (such as Notepad), Save As... and save it with the formatting as filename.html. If you don't specify the file type when saving, Notepad will default to adding the text file extension.

Upvotes: 2

knowndead
knowndead

Reputation: 80

your html is fine my bet is you saved it as index.html.txt(on accident) Could you please check for that :)

Upvotes: 2

Related Questions