Span and Div)

Source: Internet
Author: User
Difference between Span and Div

The difference between Span and DIV is:

The first explanation:

Division is a block-level element that can contain paragraphs, titles, tables, and even chapters, summaries, and remarks. While span is a row element.

The front and back of a span do not have line breaks. It has no structure meaning and is purely an application style. When any element in other rows is inappropriate, you can use span.

<Span> the span tag has an important and practical feature, that is, it does nothing, and its only purpose is to focus on your HTMLCodeAnd you can specify styles for them. <Span> the identifier allows you to divide a paragraph into different parts.

<Div> div is also used to create a logical part in an HTML file. However, unlike <div> span, <div> works at the text block level and is introduced before and after the HTML elements it contains.Line separation.

The second explanation:


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 ).
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.


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.