简体   繁体   中英

How do you open html in google chrome?

[I got it working now, it was just a browser error] My code is:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>

</body>
</html>

So the page should have the title, Test, but no, it just shows my code.So in a new tab it shows:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>

</body>
</html>

instead. Can I get it to say the title? Thanks in advance...

As a recent Mac OS adopter I too ran into this. For me, it was due to using TextEdit , and expecting it to act like Notepad.

When you save a .html file in TextEdit, it encodes the HTML and wraps it for you, without any notification.

Viewing source, or opening the file in vim or more in terminal shows what has been applied:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1265">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica; min-height: 16.0px}
  </style>
</head>
<body>
<p class="p1">&lt;!DOCTYPE html&gt;</p>
<p class="p1">&lt;html&gt;</p>
<p class="p1">&lt;head&gt;</p>
<p class="p1">&lt;title&gt;Test&lt;/title&gt;</p>
<p class="p1">&lt;/head&gt;</p>
<p class="p1">&lt;body&gt;</p>
<p class="p2"><br></p>
<p class="p1">&lt;/body&gt;</p>
<p class="p1">&lt;/html&gt;</p>
</body>
</html>

You have a problem in your <title> tag.

Sobstitute <title>Test</title> with <title>Test</title> .

Check that you've saved your html page .html extension and you should also do better to add a doctype like <!DOCTYPE html> at the beginning of your web-page .

<title>Test<title> - you have not closed the second title tag, change it to </title> . And just to be sure - Title does not have to show up in the page you open. If you want to actually see the title, add it within your <body> like this:

<body>
    <h1>Title</h1>
</body>

I copied and pasted your code into textmate saved the file as test.html and doubled clicked on it.

It worked perfectly. It seems like a browser issue, have you tried reinstalling them. How about try it on another computer? Is the file name end with .html?

how about

<html>
<head> 
    <title>Hi</title>
</head>

<body>
    <p>Are you working?</p>
</body>

</html>

does that work?

打开文件的属性(右键单击->属性),然后检查文件的名称是否为“ fileName.html.text”,如果是,则需要转到“文件夹选项”->“查看”->并取消标记“隐藏已知文件类型的扩展名”,现在将文件名更改为“ fileName.html”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM