你不应该那样使用标题。标题内容很重要,是的,但这并不意味着重要的内容应该是标题。您的第一个示例无效(列表可能仅包含li
元素),您的第二个示例与文档大纲混淆。
该strong
元素代表“对其内容的强烈重要性”。strong
您可以通过对相同内容使用多个元素来增加重要性:
一段内容的相对重要性由其祖先strong
元素的数量给出;每个strong
元素都会增加其内容的重要性。
HTML5 规范也有一个这样的用法示例:
<p>
<strong>Warning.</strong> This dungeon is dangerous.
<strong>Avoid the ducks.</strong> Take any gold you find.
<strong><strong>Do not take any of the diamonds</strong>,
they are explosive and <strong>will destroy anything within
ten meters.</strong></strong> You have been warned.
</p>
(注意<strong>Do not take any of the diamonds</strong>
嵌套在另一个strong
元素中)
所以这是HTML5中的正确方法。
关于您的示例:如果您有一个从最不重要到最重要(或相反)排序的愿望清单,您应该使用ol
而不是ul
,因为顺序是有意义且重要的。因此,您的愿望清单可能如下所示:
<ol reversed>
<li><!-- least important item --></li>
<li><!-- another not-soo-very important one --></li>
<li><strong><!-- important --></strong></li>
<li><strong><!-- more important than the previous one, but not that much of a difference --></strong></li>
<li><strong><strong><!-- most important item --></strong></strong></li>
</ol>
(如果没有以这种方式排序,请相应地使用ul
并使用strong
元素。)
现在,您当然可以使用 RDFa 或 Microdata 来增强它。因此,您需要一个适当的词汇表。我一个都不知道。也许您可以使用某种评分词汇?你可以给每个项目打分/评分,比如你想要多少。
Turtle 中的理论示例:
myWishlistItems:1 ex:hasImportance 0.9
myWishlistItems:2 ex:hasImportance 0.85
myWishlistItems:3 ex:hasImportance 0.7
myWishlistItems:4 ex:hasImportance 0.7
myWishlistItems:5 ex:hasImportance 0.7
myWishlistItems:6 ex:hasImportance 0.2
备选方案:说明内容中的语义,例如对重要性级别进行分组。
您可以使用dl
,例如:
<section>
<h1>My wishlist</h1>
<dl>
<dt>MUST HAVE!</dt>
<dd>…</dd>
<dd>…</dd>
<dt>Would be very cool</dt>
<dd>…</dd>
<dd>…</dd>
<dt>I like that, sometimes</dt>
<dd>…</dd>
<dd>…</dd>
</dl>
</section>
或ol
带有section
元素,因此您可以使用分组标题,例如:
<section>
<h1>My wishlist</h1>
<ol>
<li>
<section>
<h2>MUST HAVE!</h2>
<ul>
<li>…</li>
<li>…</li>
</ul>
</section>
</li>
<li>
<section>
<h2>Would be very cool</h2>
<ul>
<li>…</li>
<li>…</li>
</ul>
</section>
</li>
<li>
<section>
<h2>I like that, sometimes</h2>
<ul>
<li>…</li>
<li>…</li>
</ul>
</section>
</li>
</ol>
</section>