Home > Web Front-end > CSS Tutorial > 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

云罗郡主
Release: 2018-11-20 16:37:56
forward
4005 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:divcss5.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template