在 html 列表元素中包含空白行的正确方法是什么?

新手上路,请多包涵

假设我有一个列表:

  • 项目一
  • 第二条真的很长。事实上,它由几个不同的段落组成。我真的很希望能够在第二句和第三句之间休息一下,否则它们会聚在一起并且很难阅读。
  • 第三项

在 HTML/CSS 中实现此目的的正确方法是什么:

  • 项目一

  • 第二条真的很长。事实上,它由几个不同的段落组成。

我真的很希望能够在第二句和第三句之间休息一下,否则它们会聚在一起并且很难阅读。

  • 第三项

It seems some options are <p> , <div> , and perhaps <span> with the appropriate display style.可能还有更多选择,但我希望有一个正确/推荐的方法。

为了确定这个问题的范围,我们假设现代浏览器支持 HTML5/CSS3。

编辑:对于投票结束问题的人,您能否就原因发表评论?如果有一些明显的指导方针我应该遵循,请链接到它。鉴于通常有多种方法可以在 HTML/CSS 中完成任务,我认为询问是否存在“正确”的方法是公平的。

原文由 Jedidja 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 223
2 个回答

<p> 代表段落,所以这是推荐的方式,但是,所有其他方式也有效。

原文由 Itay Gal 发布,翻译遵循 CC BY-SA 3.0 许可协议

<span> 不推荐,因为它不是块元素。

您可以使用 <br>

 <ul>
  <li>
    Item One
  </li>

  <li>
    Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.
    <br><br>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.
  </li>
  <li>
    Item Three
  </li>
</ul>

您也可以使用一个空的 block 元素并使用 CSS 为其设置大小:

 .spacer {
  height: 10px;
}
 Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.
<div class="spacer"></div>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.

或者 <p> 标签:

     <p>Item Two is really long. As a matter of fact, it's made up of a couple different paragraphs.</p>
    <p>I'd really like to be able to have a break between the second and third sentence because otherwise it gets all bunched together and is really difficult to read.</p>

原文由 Magicprog.fr 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题