在哪里添加 HTML5 标签?
假设您想要对网站的标头部分使用
标记。但目前您的标头由 3 个元素组成(由于设计相关的原因),例如:
<div id="header-wrap">
<div id="header">
<div id="header-content">
...
</div>
</div>
</div>
那么这些 DIV 中的哪一个应该替换为
?这有关系吗?Let's say you want to use a <header>
tag for the header part of your site.
But currently your header is made from 3 elements (because of design-related reasons), like:
<div id="header-wrap">
<div id="header">
<div id="header-content">
...
</div>
</div>
</div>
So which one of these DIVs should be replaced with <header>
? And does it matter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML5 新标签的目的是为文档添加语义。另一方面,像
这样的通用元素被保留下来正是因为它们没有语义含义。它们非常适合在不影响语义结构的情况下添加视觉结构。
元素应包含语义标头。我敢说它很可能是最外层的元素,应该是
因为所有涉及的元素显然都存在以某种方式支持标题,但只有您最清楚文档的语义含义,这样你最好能具体回答。
A purpose of HTML5's new tags is to add semantic meaning to your document. On the other hand, generic elements like
<div>
have been preserved precisely because they have no semantic meaning. They are ideal for adding visual structure without impacting the semantic structure.The
<header>
element should envelop the semantic header. I would venture to say it's most likely the outermost element that should be<header>
since all elements involved clearly exist to support the header in some fashion, but only you know the semantic meaning of your document best, so you can best answer specifically.