问题描述
有什么区别
< br style =clear:both;/>
vs
< div style =clear:both;/>
??
另外,我想
< div style =clear:both;/>
是清除的好方法,但是
< div style =clear:both;> < / DIV>
一个合适的方法?
区别在于您继承的其他样式属性。当然一个继承自< br> ,另一个从< div> 。
$ b $
通常 < div> 除了 display:block ,而< br> 表示换行符和一些非零高度(与当前字体高度相关)。
但通常(例如,随着无处不在的 css-reset 技术)几乎没有区别。因此,选择一个最具有语义意义的方法。
[UPDATE]
<对于结束标记,请使用< div>< / div> 而不是< div /> 。 。
感谢评论员和进行结束标记更正。
What is the difference
<br style="clear:both;"/>
vs
<div style="clear:both;"/>
??
Also, I thought
<div style="clear:both;"/>
is a good way of clearing, but is
<div style="clear:both;"> </div>
a proper way?
The difference is which other style attributes you inherit. Of course one inherits from <br> and the other from <div>.
Typically <div> has no special style implications other than display:block whereas <br> implies a line-break and some non-zero height (linked to the current font height).
But often (e.g. with the ubiquitous css-reset technique) there is approximentally no difference. Therefore, pick the one that makes the most semantic sense.
[UPDATE]
For closing tags, use <div></div> and not <div/>. Here's why.
Thanks to commentors Sebastian Celis and ephemient for the "closing tag" correction.
这篇关于<峰; br /> vs< div />在清理中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!