文章内的多篇文章的语义标记与前导/后记

时间:2015-01-29 11:56:43

标签: html5 semantic-markup article

作为与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?

1 个答案:

答案 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 typeaddress 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>