用于从<article>中排除内容的HTML5标记/属性

时间:2016-04-16 14:15:51

标签: html5 semantic-markup

有没有办法让webcrawlers / bots明白文章或部分中包含的内容与文章无关?

<article>
    <section>
        <div>
            <span>Amy Neville</span>
            <img src="http://www.example.com/amy.png">
            <span>Joined <time>5 Days</time> ago</span>
            <span>41525 Points</span>
        </div>
        <p>Mary, the only surviving legitimate child of King James V of Scotland, was six days old when her father died and she acceded to the throne. She spent most of her childhood in France while Scotland was ruled by regents, and in 1558, she married the Dauphin of France, Francis. He ascended the French throne as King Francis II in 1559, and Mary briefly became queen consort of France, until his death in December 1560.</p>
    </section>
</article>

在上面的示例中,我有一个论坛帖子。旁边是<div>,其中包含有关发布该帖子的人的一些无关信息。不相关,但可能与实际文章内容混淆。

是否有任何标记或属性可以明确这一点?

1 个答案:

答案 0 :(得分:2)

一般来说,如果切片元素包含的信息 与该部分的内容完全无关,那么您最接近的信息就是<aside>元素。

发布文章的人的信息与文章相关,因为它描述了文章的作者。它不构成文章内容的一部分,但它仍然是相关的。

话虽如此,您可以使用<header><footer>在切片元素中标记作者信息。你甚至可以在一个部分的开头有一个<footer> - 它可能看起来很奇怪,但它完全没问题(参见spec describing the <article> element)。

<article>
    <section>
        <footer>
            <span>Amy Neville</span>
            <img src="http://www.example.com/amy.png">
            <span>Joined <time>5 Days</time> ago</span>
            <span>41525 Points</span>
        </footer>
        <p>Mary, the only surviving legitimate child of King James V of Scotland, was six days old when her father died and she acceded to the throne. She spent most of her childhood in France while Scotland was ruled by regents, and in 1558, she married the Dauphin of France, Francis. He ascended the French throne as King Francis II in 1559, and Mary briefly became queen consort of France, until his death in December 1560.</p>
    </section>
</article>

除了<address>元素外,没有用于标记作者信息的专用元素,但<address>用于联系信息。