Home  >  Article  >  Web Front-end  >  What is the difference between Span and Div? Detailed explanation of the difference between Span and Div

What is the difference between Span and Div? Detailed explanation of the difference between Span and Div

云罗郡主
云罗郡主forward
2018-11-20 16:37:563918browse

This article brings you what is the difference between Span and Div? The detailed explanation of the difference between Span and Div has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

HTML is just a means of giving content. Most HTML tags have their own 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. Listen It looks as useless as a hammer made of foam. 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 class 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 used in a small piece of inline HTML, while div (think about what division means) elements are block-level (simply put , which is equivalent to a line break before and after it), used to combine a large block of code. The code is as follows:

<div id=”scissors”> <p>This is <span class=”paper”>crazy</span></p> </div>

In practice, divs and especially spans should not be abused, despite other opinions to the contrary. For example, if you want to emphasize the word "crazy" and the bold "paper", you may use code like this:

<div id=”scissors”> <p>This is <strong class=”paper”>crazy</strong></p> </div>

What is the difference between Span and Div? A detailed introduction to the difference between Span and Div. If you want to know more about CSS3Tutorial, please pay attention to the PHP Chinese website.


The above is the detailed content of What is the difference between Span and Div? Detailed explanation of the difference between Span and Div. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:divcss5.com. If there is any infringement, please contact admin@php.cn delete