SPAN元素和DIV元素有的区别
DIV是块元素,SPAN是内嵌元素。块元素相当于内嵌元素在前后各加一个<br>换行。其实,块元素和行内元素也不是一成不变的,只要给块 元素定义display:inline,块元素就成了内嵌元素,同样地,给内嵌元素定义了display: block就成了块元素了。
代码
<style>
div,span{border:1px solid #f00;margin:2}
</style>
<div>div1</div><div>div2</div>
<span>span1</span><span>span2</span>
<div style="display:inline">div3</div>
<div style="display:inline">div4</div>
<span style="display:block">span3</span>
<span style="display:block">span4</span>
div,span{border:1px solid #f00;margin:2}
</style>
<div>div1</div><div>div2</div>
<span>span1</span><span>span2</span>
<div style="display:inline">div3</div>
<div style="display:inline">div4</div>
<span style="display:block">span3</span>
<span style="display:block">span4</span>