The difference between DIV and SPAN
This article mainly introduces "the difference between DIV and SPAN". In daily operation, I believe that many people have doubts about the difference between DIV and SPAN. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "the difference between DIV and SPAN". Next, please follow the editor to study!
Deeply understand the difference between DIV and SPAN
DIV block element, span is an inline element
The width of the Span depends on the width of the surrounding object, so you cannot use the width attribute width to set the width of the object within the span tag, but you can set the margin (external patch) value of the span, and the distance between the object position in the span and the parent object.
L Div block elements wrap at 100%
Actual length of Span inline element text
L block elements and inline elements are not immutable, and they can be transformed into each other by defining the display attribute value of CSS.
Eg:#div {display:inherit;} # span {display:block;}
When to use span
Use span tags when you want to style Chinese characters or pictures on the same line without wrapping the line of text
At this point, the study of "the difference between DIV and SPAN" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!