使用br或div进行分节符 [英] Using br or div for section break

查看:79
本文介绍了使用br或div进行分节符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几个地方工作过,看到了两种不同的方法来在HTML中进行节或换行.

I've worked at few places and seen two different methods of doing a section or line break in HTML.

我看到它完成的一种方式是这样的:

One way I've seen it done is like this:

<div class="placeholder-100pct">&nbsp;</div>

另外一个只是使用普通的<br />.

And the other is just using plain old <br />.

对彼此有益吗?还是只是风格问题?

Any benefit to one over the other or would it be just a matter of style?

推荐答案

在段落中需要换行时,请使用<br/>,例如:

Use <br/> when you want a new line in a paragraph, like so:

<p>Hi Josh, <br/> How are you?</p>

这在写地址时可能有用:

This might be useful when writing an address:

<p>John Dough<br/>
1155 Saint. St. #33<br/>
Orlando, FL 32765
</p>

使用div会自动给您换行,但是如果要在两个元素之间留一个空格,可以在div上使用边距.

Using a div will automatically give you a new line, but if you want a space between two elements, you can use a margin on the div.

请勿使用<br/>在两个div之间获取一些空间:

Do not use <br/> to get some space between two divs:

<!-- This is not preferred -->
<div>Hello</div>
<br/>
<div>Something else here</div>

希望这会有所帮助

这篇关于使用br或div进行分节符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆