Home > Backend Development > PHP Tutorial > float:left and span tags of div

float:left and span tags of div

WBOY
Release: 2016-07-29 09:03:13
Original
1929 people have browsed it

<div style="width: 300px;">
	<div style="float: left;width: 100px;">
		我是div
	</div>
	<span style="">
		span
	</span>
	<span>
		span
	</span>
</div>
Copy after login

In the above code, the div has float:left and the span does not have float:left, but the span tag is still displayed on the right side of the div tag instead of being covered by the div tag. This is because the span tag is an inline element and not a block-level element.

?The following is the difference between the two of them:

The difference between div and span

The difference is that div

? is a block-level (block-level) element, and the elements it surrounds will Automatic line wrapping. And span is just an inline element (inline element), there will be no line breaks before and after it. There is no structural meaning, it is purely applied style, and can be used when other inline elements are not suitable. It should be noted that the mark can be included in the mark and become its child element, but the reverse is not true, that is, the mark cannot contain the mark

The above introduces the float:left and span tags of div, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template