Question

I am using Sublime Text 2 to write my testing html file. I save the text as HTML format. Then when I try to open the file with browser by either drag&drop or Open_With...

Then.....

The browser open my plain text file, not the actual html. This is what it look like. Just white background and these text.

<!DOCTYPE html>
<head>
    <title>A Hello World Page</title>
</head>
<body>
<p>Hello World</p>
</body>

This is my first time with html ever, do I have to do special setup with anything? I just use default SublimeText2.

Was it helpful?

Solution

That may be because you are missing the main tag <html>.

Do this:

<!DOCTYPE html>
<html>
  <head>
     <title>A Hello World Page</title>
  </head>
  <body>
    <p>Hello World</p>
  </body>
</html>

<html> is the main tag, browser will look for to tell whether it is html or not.

Also make sure it is saved as .html or .htm

OTHER TIPS

Open up Sublime Text, press CTRL SHIFT + P.

Type in HTML into the box and select Set syntax: HTML.

Then, in the file, type in html then press tab straight after and it should create a snippet (which is default):

<html>
<head>
    <title></title>
</head>
<body>

</body>
</html>

Then make sure you save the document as .html or .htm.

This should work in your browser after.

Note: Setting syntax and doing snippet wont actually 'help' in terms of this question, but will help you in HTML by making things quicker and having syntax highlighting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top