在HTML5中的段落中放置列表的正确方法是什么?

我得到了为什么< p>元素不能包含< ul>元件.不幸的是,这并不能帮助我,因为这是内容的结构.

在元,我也不明白

>语义解释,也不是
>推荐结构

对于我实际上想要显示具有正常内容的“内联”项目列表的情况.

This page建议将列表与段落分开:

<p>For instance,this fantastic sentence has bullets relating to</p>
<ul>
 <li>wizards,<li>faster-than-light travel,and
 <li>telepathy,</ul>
<p>and is further discussed below.</p>

或使用该段落的替代标签

<div>For instance,this fantastic sentence has bullets relating to
<ul>
 <li>wizards,</ul>
and is further discussed below.</div>

但是,这两个都把我当作可怕的黑客,嘲笑HTML5的语义内容.

在第一种情况下,< p>标签语义有意义更不用说如果我想消除列表周围的间距(如果我有其他的列表,真的是分开的内容块 – 呃!

在第二种情况下,如果我需要一个< div>这意味着“这是一段内容”我也可以放下< p>而不是根据段落中出现的内容来回切换.

最具语义意义的版本的ISTM可能类似于:

<p>For instance,this fantastic sentence has bullets relating to
 <span class="li">wizards,</span>
 <span class="li">faster-than-light travel,and</span>
 <span class="li">telepathy,</span>
and is further discussed below.</p>

跨度被设计为块或列表项(并且谁知道什么其他调整)来获得渲染权.实际上,这听起来很糟糕.

有没有很好的建议来呈现这种内容

编辑

这实际上并不是那么难做的风格,似乎.我不知道是否有办法接收所有的浏览器认值,但我可以复制认列表样式(至少在OS X Chrome上):

span.li {
  display: list-item;
  list-style-type: disc;
  margin-left: 40px;
}

解决方法

对我来说,这是一个列举例子,或者看到每一个事情序列都是需要标记的列表.

我的第一种方法标记你所拥有的:

<p>For instance,this fantastic sentence has bullets relating to wizards,faster-than-light travel,and telepathy,and is further discussed below.</p>

如果您需要对这些项目应用一个通用的样式,那么相应的样式钩子是< span>就像你在最后一个例子中所说的那样.我不会使用李作为一个类名;每个文本的废稿是否构成列表项都不是很有意义.在不知道页面的整体内容以及如何在上下文中使用的情况下,选择正确的类名是很困难的,但可能主题将是一个适当的选择.所以标记变成了

<p>For instance,this fantastic sentence has bullets relating to <span
class="topic">wizards</span>,<span class="topic">faster-than-light 
travel</span>,and <span class="topic">telepathy</span>,and is further 
discussed below.</p>

相关文章

HTML5和CSS3实现3D展示商品信息的代码
利用HTML5中的Canvas绘制笑脸的代码
Html5剪切板功能的实现
如何通过HTML5触摸事件实现移动端简易进度条
Html5移动端获奖无缝滚动动画实现
关于HTML5和CSS3实现机器猫的代码