What is the difference between Div and span?
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> <div> A new line is displayed. </div>
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 <Div style = "display: inline"> test </div> <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.
Note
The running effects of the two sections of code in this example are 1.3.5 and 1.3.6 respectively.
Figure 1.3.5 Div and span rendering Effect Test
Figure 1.3.6 mutual conversion between elements in a row and those in a row
Note
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.