是HTML5<标题>如果只有一个< hx>里面有标签? [英] Is an HTML5 <header> tag unnecessary if there is only a single <hx> tag inside it?

查看:120
本文介绍了是HTML5<标题>如果只有一个< hx>里面有标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索过,但没有提出任何有用的答案,所以请点击:

I've searched and have not come up with any useful answers, so here goes:

HTML5 < header> 如果里面只有一个< hx> 标签,则标签是不必要的?例如,我有以下HTML5标记:

Is an HTML5 <header> tag unnecessary if there is only a single <hx> tag inside it? For instance, I have the following HTML5 markup:

<article>

   <header>
      <h1>Heading Title</h1>
   </header>

   ...

</article>

从HTML5语义的角度来看,当只有一个<在< header> 内没有别的,是< header> 标记不必要/冗余,我应该这样做:

From an HTML5 semantics point of view, when there is only one <hx> tag inside the <header> and nothing else, is the <header> tag unnecessary/redundant, and should I just do this instead:

<article>

   <h1>Heading Title</h1>

   ...

</article>


推荐答案

从W3C的标题 spec的第一个注释部分<上面提到的 ajp15243 ,重点是我的:

From the first Note section on the W3C's header spec which ajp15243 mentioned above, emphasis mine:


标题元素通常包含节的标题(h1-h6元素),但这不是必需的。 header元素还可用于包装部分的目录,搜索表单或任何相关徽标。

A header element is intended to usually contain the section's heading (an h1–h6 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.

如果你们所有人< h1>< / h1> < header> 标签不是您的文档正确形成和语义正确所必需的。

If all you have is a single (as per your example) <h1></h1>, the <header> tag is not required for your document to be properly-formed and semantically correct.

您可能会发现拥有< header> 元素有助于您稍后使用CSS设置 h1 的样式,但就本例中的HTML而言,您在语义上都很好或没有< header>

You might find that having the <header> element as a wrapper aids you in styling the h1 later with CSS, but as far as the HTML alone in this case, you're semantically fine either with or without <header>.

这篇关于是HTML5&lt;标题&gt;如果只有一个&lt; hx&gt;里面有标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆