作为与another question相关的项目的一部分,我需要在语义HTML5中标记嵌套文章。有一篇杂志文章,其中包含不同作者的一些简短文本以及一些编辑评论。在目前的HTML4版本中,它看起来像这样:
<div id="article">
<h1>Main heading - a collection of texts</h1>
<p id="intro">
A general introduction to the whole collection by the editor.
</p>
<p class="preamble">
A few words from the editor about the first text.
</p>
<h2>First text heading</h2>
<p>First text. Lorem ipsum ...</p>
<p class="author">
Name of author of first text.
</p>
<div>*</div>
<p class="preamble">
A few words from the editor about the second text.
</p>
<h2>Second text heading</h2>
<p>Second text. Dolorem ipsum ...</p>
<p class="author">
Name of author of second text.
</p>
<p id="postscript">
Some final words about the whole collection by the editor.
</p>
<div>
我在HTML5中一直在考虑这样的事情,但有些元素我根本不知道什么是最好的:
<article>
<header>
<h1>Main heading</h1>
<ELEMENT>
General introduction
</ELEMENT>
</header>
<article>
<header>
<ELEMENT>
Preamble
</ELEMENT>
<h2>
Article heading
</h2>
</header>
<p>
Article text
</p>
<ELEMENT>
Name of author
</ELEMENT>
</article>
<div>*</div>
<article>
Second article ...
</article>
<ELEMENT>
Postscript by editor
</ELEMENT>
</article>
我是否应该使用带有类名的p
元素用于各种介绍和postscript,或者aside
元素?别的什么?关于作者姓名的同样问题。 address
元素似乎不太合适。一个footer
或许还有一些其他元素(?)?
编辑:偶尔也有一些图像,文章末尾的小字体中提到了摄影师(“照片:John Doe。”)。 footer
中的元素x?
答案 0 :(得分:0)
我认为第一个问题应该是 where 来为文章添加编辑评论。我可以想到三种方式:
(a)编辑评论header
的{{1}}
article
(b) <article class="author-text">
<header class="editor-comment"></header>
</article>
嵌套在article
article
(c)编辑评论<article class="author-text">
<article class="editor-comment"></article>
</article>
section
为孩子
article
您在问题中使用(a)。我不认为这是最好的选择,主要是因为这个<section class="editor-comment">
<article class="author-text"></article>
</section>
将包含来自不同作者的内容(不能一起工作),所以“最近article
元素祖先”的概念用于表示作者身份不行。例如,它由author
link type和address
element使用。
(b)和(c)没有此问题。在(b)中,每位编辑都可以拥有自己的作者信息,在(c)中,编辑的作者信息将从父article
中获取(其中包括整篇文章集,因此每次编辑都必须是相同的。
definition of article
表明(b)是合适的:
当
article
元素嵌套时,内部article
元素表示原则上与外部文章内容相关的文章。
将此编辑器评论article
包含在article
。
作者身份信息可以放在header
中。 Only if此信息包含作者的联系信息,另外使用footer
元素(仅适用于这些联系信息部分)。
因此,单个短文本可能如下所示:
address
整个系列的结构可以这样:
<article class="author-text">
<h1>First text heading</h1>
<header>
<article>
<p>Editor comment</p>
</article>
</header>
<p>First paragraph of the text …</p>
<footer>
<!-- text author information -->
<!-- use 'address' here if appropriate -->
</footer>
</article>