문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top