Html 杂散的结束标签“头”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15367800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stray end tag "head"
提问by Ramy Al Zuhouri
I have the following html5 code:
我有以下 html5 代码:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="Style.css" rel="stylesheet" type="text/css">
<title>Catalogo Dischi</title>
<p class="title"> Catalogo Dischi </p>
<a id="index">
<p class="subtitle">Indice</p>
</a>
<p class="text">
<a href="#classic">Musica Classica</a>
<br/>
<a href="#jazz">Musica Jazz</a>
<br/>
<a href="#country">Musica Country</a>
</p>
</head>
The code is inside the html tag. I don't understand the reason of this error, I close all tags except for meta and link, which can't be closed, what's the problem?
代码在 html 标签内。我不明白这个错误的原因,我关闭了除meta和link之外的所有标签,无法关闭,有什么问题?
回答by Nick Andriopoulos
you need to understand -- the <head>
element defines attributes that are used by the browser, but are not directly visible in the page. The <title>
attribute defines the title shown on your browser tab.
您需要了解——该<head>
元素定义了浏览器使用但在页面中不直接可见的属性。该<title>
属性定义了浏览器选项卡上显示的标题。
After you close the <head>
tag, you should open the <body>
tag, in which all the content to be shown in the page should go.
关闭<head>
标签后,您应该打开<body>
标签,页面中要显示的所有内容都应该在其中。
Also see http://reference.sitepoint.com/html/page-structurefor a basic introduction to these elements.
有关这些元素的基本介绍,另请参阅http://reference.sitepoint.com/html/page-structure。
回答by internals-in
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="Style.css" rel="stylesheet" type="text/css">
<title>Catalogo Dischi</title>
</head>
<body>
<p class="title"> Catalogo Dischi </p>
<a id="index">
<p class="subtitle">Indice</p>
</a>
<p class="text">
<a href="#classic">Musica Classica</a>
<br/>
<a href="#jazz">Musica Jazz</a>
<br/>
<a href="#country">Musica Country</a>
</p>
</body>
回答by user1936123
You need to close the head
tag after your title and wrap your content in body
tags.
您需要head
在标题后关闭标签并将您的内容包装在body
标签中。
回答by panky sharma
Error may occured if there is an issue of type or double tab in head section. suppose title is like this
如果头部有类型或双制表符的问题,可能会发生错误。假设标题是这样的
<title> Foundation </title>>
Then Stray end tag “head” will occur including error in body
然后会出现杂散的结束标记“head”,包括正文中的错误
If page opened in Chrome then it will add a > right after 'Body' tag
如果页面在 Chrome 中打开,那么它会在“Body”标签之后添加一个 >
<body>
">"
回答by Joel A Delphin
This is your charset charset=UTF-8"
it's missing the "
at the beginning.
这是您的字符集, charset=UTF-8"
它"
在开头缺少。
回答by Makurious
i solved mine by doing this to my code i show you the tag example so you can see what i did to the tags.
我通过对我的代码执行此操作解决了我的问题 我向您展示了标签示例,以便您可以看到我对标签做了什么。
so with a link tag it would be:
所以使用链接标签将是:
<link href='https://fonts.googleapis.com/css?family=Aclonica%7cPlayfair+Display' rel='stylesheet'/>
notice on the end the link tag just ends with />
注意链接标签最后以 /> 结尾
回答by Neophile
In your code you have placed <p>
inside <head>
when the
在你的代码已经放在<p>
里面<head>
当
starts it indicates body part but so after
开始它表示身体部位,但之后
all thing goes under body so closing </head>
is an error
所有的东西都在身体下面所以关闭</head>
是一个错误