假设我有一个清单:
在HTML / CSS中实现此目的的正确方法是什么:
第二项真的很长。事实上,它由几个不同的段落组成。
我真的希望能够在第二句和第三句之间休息一下,因为否则它会聚在一起并且很难阅读。
似乎某些选项是<p>
,<div>
,也许<span>
具有相应的display
样式。可能还有更多选择,但我希望有一个正确/推荐的方法。
为了确定这个问题的范围,我们假设现代浏览器支持HTML5 / CSS3。
编辑:对于投票结束问题的人,您能否就其原因发表评论?如果我应该遵循一些明显的指导原则,请链接到它。鉴于通常有多种方法可以在HTML / CSS中完成任务,我认为可以确定是否存在&#34;正确的&#34;方式。
答案 0 :(得分:6)
<p>
代表段落,所以这是推荐的方式,但是,所有其他方式也是有效的。
答案 1 :(得分:4)
<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>
&#13;
您也可以使用空的block
元素并使用CSS设置大小:
.spacer {
height: 10px;
}
&#13;
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.
&#13;
或<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>
&#13;
答案 2 :(得分:0)
只需添加一下,将<br>
或<p>
放在<li>
之外但放在父<ul>
内时,使用html验证程序进行检查会引发错误。
因此可以接受:
<ul>
<li>
.....
<br>
</li>
</ul>
,但不是。
<ul>
<li>
.....
</li>
<br>
</ul>
对于许多人来说,这可能是清楚的或合乎逻辑的,但是我今天必须学习这一点,特别是因为该线程鼓励我
是正确的方法(= element),但仅仅是我的位置是错误的。>
答案 3 :(得分:0)
我使用<hr>
是因为它是表示这种中断的语义标记。
由于历史原因,该元素显示为水平线,因此需要一些CSS才能更改外观。
<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.
<hr style="border: none;">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>