<分区>
<分区>
当使用clear:both样式的DIV元素清除之前的 float 时,是否需要在DIV元素上使用开始和结束标签?这是一个例子......
这样可以吗?
<div style="clear:both;" />
还是应该这样?
<div style="clear:both;"></div>
最佳答案
你需要结束标签,或者浏览器will not think the tag is closed .
但是,您为什么还要使用 <div style="clear:both;"></div>
?这涉及添加额外的非语义 div
没有理由。
有更好的方法来包含/清除 float :
overflow: hidden
在包含您的花车的元素上。关于html - 是否需要使用带有 <div> 的结束标记来清除 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9279244/