Html “head”和“header”标签之间的真正区别是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33919706/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:33:37  来源:igfitidea点击:

What is the real difference between the "head" and "header" tag?

htmlheaderhead

提问by makertech81

The Question

问题

I've been coding for a while and realized that the head and header look exactly the same. Are they the same, and what is the difference between them? Does it make a difference?

我已经编码了一段时间并意识到头部和标题看起来完全相同。它们相同吗,它们之间有什么区别?这有什么不同吗?

After researching a bit I couldn't find much info on this, I may not have been digging deep enough. The info I found was that the <head>tag came out since HTML 1 as the <header>tag came out in HTML5. Is one more stable from the other?

经过一番研究后,我找不到太多关于此的信息,我可能挖掘得不够深。我发现的信息是该<head>标签从 HTML 1<header>开始就出现在 HTML5 中。一个比另一个更稳定吗?

Summary

概括

I would like to understand the difference between the two tags. I would like a creditable/ or official source. If you can please post the link of where you got the information. A example of the code would be helpful too! The main question I am asking is whether there is a difference and if so what difference is there. Is there a benefit from one of them? Thank you for taking the time to read this.

我想了解这两个标签之间的区别。我想要一个可靠的/或官方来源。如果可以,请张贴您获得信息的链接。代码示例也会有所帮助!我要问的主要问题是是否有区别,如果有,有什么区别。其中之一有好处吗?感谢您抽出时间来阅读。

回答by Arena

A quick Google search reveals the following:

快速谷歌搜索显示以下内容:

Head tag:
The HTML <head>element provides general information (metadata) about the document, including its title and links to/definitions of scripts and style sheets. (HTML MDN)

Head 标签:
HTML<head>元素提供有关文档的一般信息(元数据),包括其标题以及指向/定义脚本和样式表的链接。(HTML MDN)

Header tag:
The HTML <header>element represents a group of introductory or navigational aids. It may contain some heading elements but also other elements like a logo, wrapped section's header, a search form, and so on. (HTML MDN)

标题标签:
HTML<header>元素代表一组介绍性或导航性的帮助。它可能包含一些标题元素,但也包含其他元素,如徽标、包装部分的标题、搜索表单等。(HTML MDN)

-

——

In other words; the head tag is used for document title, styling, scripts, etc.
Whereas the header tag is used for headers as seen in articles.

换句话说; head 标签用于文档标题、样式、脚本等。
而 header 标签用于文章中的标题。

Newspaper 'header'.Newspaper 'header'

报纸“标题”。报纸“标题”

EDIT: Updated reference, as psuedocodermentioned, W3Schools is not always fully reliable.

编辑:更新参考,如伪编码器提到的,W3Schools 并不总是完全可靠。

回答by pseudocoder

From W3C:

来自 W3C:

https://www.w3.org/wiki/HTML/Elements/head

https://www.w3.org/wiki/HTML/Elements/head

"The <head>element represents a collection of metadata for the Document."

“该<head>元素表示文档的元数据集合。”

https://www.w3.org/wiki/HTML/Elements/header

https://www.w3.org/wiki/HTML/Elements/header

"The <header>element represents a group of introductory or navigational aids."

“该<header>元素代表一组介绍性或导航性的帮助。”

The main difference is that the <head>element is for META data and the <header>element is for actual content.

主要区别在于<head>元素用于元数据,<header>元素用于实际内容。

回答by Vecta

The HTML <head>tagis a container for metadata and links to scripts and stylesheets.

HTML<head>标记是元数据以及脚本和样式表链接的容器。

The <header>tagis a semantic container used to designate contents that is introductory or navigational in nature.

<header>标签是用于指定内容是介绍性或在自然界中导航语义容器。