主要内容的 HTML5 语义文章标签
语义:您希望它们正确,但有时它们只是令人困惑。
网站文档结构:
<body>
<header>
<div id="main">
<header> (not on every page)
<div id="content">
<footer> (not on every page)
<aside>
<footer>
将 div#main 替换为 article< 在语义上是否正确/strong> 标签?
Semantics: You want to get them right but sometimes they're just confusing.
Website document structure:
<body>
<header>
<div id="main">
<header> (not on every page)
<div id="content">
<footer> (not on every page)
<aside>
<footer>
Is it semantically correct to replace div#main with an article tag?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在这个问题上复活死者,目前接受的答案很快就会是错误的。有一个针对
元素的扩展草案,旨在满足您的需求。此外,它还可以在浏览器中自动执行 ARIA
role="main"
,以实现更好的可访问性。请参阅此链接了解更多信息:https://dvcs.w3。 org/hg/html-extensions/raw-file/tip/maincontent/index.htmlTo raise the dead on this question, the currently accepted answer will soon be incorrect. There has been an extension draft for a
<main>
element targeted for exactly what you need. Furthermore it automates the ARIArole="main"
in the browser for better accessibility. Please see this link for more info: https://dvcs.w3.org/hg/html-extensions/raw-file/tip/maincontent/index.html根据 http://html5doctor.com/the-article-element/ 这是一个有效的语义编码方式。它被称为“网络博客风格
”。
根据您的结构,您也可以将
#content
替换为文章。不要忘记添加 http://code.google.com/p/html5shiv/ 和当您通过 https 为您的网站提供服务时,还要查看协议相关 Url(Google 搜索),这样您就不必检测 http 和 https 之间的切换。
As per http://html5doctor.com/the-article-element/ that is a valid semantic way of coding. It is referred to as "A weblog-style
<article>
".Depending on your structure you might be able to replace
#content
with an article as well.Do not forget to include http://code.google.com/p/html5shiv/ and while you're at it if you serve your site over https also look into Protocol Relative Url (Google for it), so you don't have to detect the switch between http and https.
我认为用
标签替换它会更合适。
标签适用于博客文章、论坛帖子或报纸文章等内容(该标签的名称由此而来)。
相反,
标签适用于文档中更通用的内容部分,因此更适合这种情况。
Mark Pilgrim 在DiveIntoHTML5.ep.io
I think it would be more appropriate to replace it with a
<section>
tag. The<article>
tag is meant for stuff like blog posts, forum posts, or newspaper articles (hence the name of the tag).In contrast, the
<section>
tag is meant for more generic parts of content in your document and thus is better suited in this case.This is all much better explained by Mark Pilgrim at DiveIntoHTML5.ep.io