HTML is just a means of giving content. Most HTML tags have their meaning (the p tag creates a paragraph, the h1 tag creates a title, etc.). However, the span and div tags do not seem to have any content meaning and sound like a bubble. A perfect hammer is as useless. But in fact, combined with CSS, they are widely used.
They are used to combine a large piece of HTML code and assign certain information. Most of them are associated with elements using the class attribute and the identification attribute id. See the class and id selectors in the CSS Intermediate Guide.
The difference between span and div is that span is inline and is used in a small block of inline HTML, while div (think about what division means) element is block-level (simply put, it is equivalent to the one before and after it). with line breaks), used to combine large chunks of code.
<div id="scissors"> <p>This is <span class="paper">crazy</span></p> </div> |
<div id="scissors"> <p>This is <strong class="paper">crazy</strong></p> </div> |
This is better than adding another span.
No clue about class and identifier? Don’t worry, you’ll get to them in the intermediate CSS guide. All you need to remember is that spans and divs are "meaningless" tags.