【问题标题】:Semantic markup of multiple articles inside article with preambles/postscript带有序言/后记的文章内多篇文章的语义标记
【发布时间】:2015-03-28 15:32:21
【问题描述】:

作为与another question 相关的项目的一部分,我需要在语义 HTML5 中标记嵌套文章。有一篇杂志文章包含不同作者的一些短文以及一些编辑 cmets。在当前的 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 元素,还是应该使用aside 元素?还有什么?关于作者姓名的同样问题。 address 元素似乎并不完全正确。 footer 中可能还有其他元素 (?)?

编辑:偶尔也有一些图像,并且在文章末尾以小字形式提到了摄影师(“照片:John Doe。”)。 footer中的元素x?

【问题讨论】:

    标签: html semantic-markup article


    【解决方案1】:

    我认为第一个问题应该是在哪里 将文章的编辑评论放在哪里。我可以想到三种方式:

    • (a)headerarticle 中编辑评论

      <article class="author-text">
        <header class="editor-comment"></header>
      </article>
      
    • (b)article 中的编辑器注释嵌套在article

      <article class="author-text">
        <article class="editor-comment"></article>
      </article>
      
    • (c)section 中的编辑器注释,其中 article 为子项

      <section class="editor-comment">
        <article class="author-text"></article>
      </section>
      

    您在问题中使用了 (a)。我不认为这是最好的选择,主要是因为这个article 将包含来自不同作者的内容(不能一起工作),所以用于表示作者身份的“最近的article 元素祖先”的概念是行不通的。例如,author link typeaddress element 使用它。

    (b)(c) 没有这个问题。在(b)中,每个编辑都可以有自己的作者信息,在(c)中,编辑的作者信息将来自父article(包括整个文章集),所以每次编辑都必须相同。

    definition of article 表明 (b) 是合适的:

    article元素嵌套时,内部article元素代表原则上与外部文章内容相关的文章。

    header 中包含此编辑评论article 是有意义的。

    作者信息可以放在footerOnly if 此信息包含作者的联系信息,另外使用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>
    

    整个集合的结构可以是这样的:

    <article class="text-collection">
    
      <h1>Main heading</h1>
    
      <p>General introduction</p>
    
      <article class="author-text"></article>
      <article class="author-text"></article>
      <article class="author-text"></article>
      <article class="author-text"></article>
    
      <p>Postscript by editor</p>
    
    </article>
    

    【讨论】:

    • 再次感谢您提供信息丰富的回复。是的,我同意h1(不是h2)是我应该为每个子文章标题(在你的例子中是“第一个文本标题”)使用的,但我不明白为什么你把它放在标题之前而不是里面它。在这种情况下会不合适吗?
    • @linurb:您不必使用h1(实际上,HTML5 recommends 可以使用“用于该部分嵌套级别的适当等级的标题”)。 -- 关于header:是的,在header 中包含标题是适当且常见的。
    猜你喜欢
    • 2015-05-01
    • 2016-09-14
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多