Html html5:使用页眉或页脚标签两次?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4837269/
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
html5: using header or footer tag twice?
提问by matt
quick question: is it actually allowed to use the header tag twice? e.g. i have two important head-sections in my header.php where both could have header tag?
快速问题:实际上是否允许使用标题标签两次?例如,我的header.php 中有两个重要的head-sections,它们都可以有header 标签?
回答by linusthe3rd
Yes, but with a catch. The W3 documents state that the tags represent the header and footer areas of their nearest ancestor section. I would recommend having as many as your want, but only 1 of each for each "section" of your page, i.e. body, section etc.
是的,但有一个问题。W3 文档声明标签代表它们最近的祖先部分的页眉和页脚区域。我建议您拥有任意数量的页面,但每个页面的每个“部分”(即正文、部分等)只有 1 个。
From W3
从 W3
A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos.
header 元素通常用于包含节的标题(h1-h6 元素或 hgroup 元素),但这不是必需的。header 元素还可用于包装部分的目录、搜索表单或任何相关徽标。
=========================
==========================
The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.
footer 元素代表其最近的祖先分节内容或分节根元素的页脚。页脚通常包含有关其部分的信息,例如作者、相关文档的链接、版权数据等。
Here are links to their respective standard documentation: headerand footer
回答by Marcus Whybrow
Yes you can use multiple header
elements in your documents, by virtuue of the w3c documentation:
是的,您可以header
通过w3c 文档的优点在文档中使用多个元素:
A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos.
header 元素通常用于包含节的标题(h1-h6 元素或 hgroup 元素),但这不是必需的。header 元素还可用于包装部分的目录、搜索表单或任何相关徽标。
However ensure that it is semantically correct.
但是请确保它在语义上是正确的。
回答by Horia Dragomir
There's no penalty for using two header tags, but make sure it makes sense.
使用两个标题标签没有任何惩罚,但要确保它有意义。
Happy coding!
快乐编码!
回答by Floern
The <header>
is used to mark the header of e.g. articles in newspaper, so if you have multiple articles you can use multiple <header>
.
该<header>
是用来标记在报纸如文章的标题,所以如果你有多个物品,你可以使用多个<header>
。
It's like using multiple <h1>
. It does only make sense in some special case.
这就像使用多个<h1>
. 它只在某些特殊情况下才有意义。
回答by iMarshal
In some situation, it is posible put two <header>
in single <article>
/<section>
like this, so why not.
在某些情况下,可以像这样将两个<header>
放在单个<article>
/ 中<section>
,那为什么不呢。
<article>
<!-- Feature Image on the LEFT -->
<div class="position-left">
...featrue image...
<header>
...H1 title ...
</header>
</div>
<!-- Content on the RIGHT with subtitle, date, etc -->
<div class="position-right">
<header>
..date, sub-title, etc...
</header>
...content...
<footer>..</footer>
</div>
</article>
回答by Scott M.
You can put two <header>
tags in your document, sure. Semantically, however, it is incorrect. Why not use one <header>
tag and use a different tag inside it?
当然,您可以<header>
在文档中放置两个标签。然而,在语义上,它是不正确的。为什么不使用一个<header>
标签并在其中使用不同的标签?