Q: What is the difference between DIV and SPAN? Many of my friends may be confused. Here, we can tell you that the biggest feature of the DIV and SPAN elements is that they do not perform any formatting and rendering on the objects in the Elements by default. Q: what is the difference between DIV and SPAN?
Answer: solution:
The biggest feature of DIV and SPAN elements is that they do not perform any formatting and rendering on objects in the element by default. It is mainly used to apply a style sheet. The most obvious difference between the two is that DIV is a block element, while SPAN is a line element (also translated as an embedded element ).
Procedure:
1. The so-called block element is the element that starts rendering with another line. The element in the line does not need to start with another line. You will have a better understanding of the Code below the test example:
Test <span> display next to test </span> <p> A new line is displayed. </p>
2. Block elements and intra-row elements are not static. They can be converted to each other by defining the display attribute values of CSS, for example:
Test <p style = "display: inline"> test </p> <span style = "display: block "> A new line is displayed here </span>
Tip: If no CSS attribute is defined for the DIV element, the display effect will be displayed on the P element.
Because of the particularity of DIV and SPAN elements, it is generally used to apply style sheets. For example, CSS is used as a layer. What needs to be distinguished is the difference between block elements and intra-row elements, there is also a mutual conversion between the two.
DIV specifies the HTML Rendering container.
SPAN specifies the embedded text container.
In general, a p occupies a block, and its default display attribute is block, indicating a block. For example:
Aaa
The bbb shows two rows.
Span, whose display attribute is inline by default, can be connected together. For example, aaabbb shows a row.
P is generally used for typographical layout, while span is generally used for partial text styles.