Difference between Span and Div

Source: Internet
Author: User

The following uses a case to illustrate the differences between the span tag and the DIV Tag: by default, the range of the span tag is all characters in the span tag, and if it is a div tag, it is a line of its label. It is not difficult to understand the case.
 
<HTML>
<Head>
<Title> Differences Between span and Div </title>
</Head>
<Body>
<! -- The background color displayed for statements within the span range is limited to the length of the word. -->
<Span style = "text-indent: 1em; Background: yellow; font-family: Courier">
I am like a boat, looking for a harbor, cannot forget you </span>
<! -- The DIV range is the whole line. It does not end the background color because of the word length, but displays the whole line. -->
<Div style = "text-indent: 2em; Background: yellow; font-family: Courier">
I am like a boat, looking for a harbor, cannot forget you </div>
</Body>
</Html>
Span and Div are both layers. I still remember a friend gave an example to illustrate the differences between them:
[HTML]
<Span> AAAA </span> <span> BBBB </span>
<Div> AAAA </div> <div> BBBB </div>
[/Html]

In the above example, the span does not wrap, while the DIV does.

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: info-contact@alibabacloud.com 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.