This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11708|Reply: 0

[HTML/HTML5] The difference between div, span, and label tags in HTML

[Copy link]
Posted on 12/18/2014 1:33:30 PM | | |
div and span
When you first learn the div+css layout, there is a lot of confusion, in the process of using div and span do not feel that there is a certain "chapter", I feel that there is not much difference between the two, in W3C about the definition of div and span: div as a split document structure naturally makes it the most official semantics, but such an official semantics is too confusing, and the big structure is also
Okay, but it's still confusing whether to use div or span for small places. In fact, it is precisely the "Microsoft MSDN Library"
The definition inside is suddenly enlightening.
div: Specifies the container for rendering HTML
span: Specifies the embedded text container
In layman's terms, div should be used if there are other tags in it, and span should be used if there is only text in it
A div is a block-level element that provides structure and context for large chunks of content within an HTML document
span is an inline element that defines an area within a line (i.e. it can be divided into several areas within a line<span>)
The div tag can be embedded with a span tag, (div can be regarded as a large container, span is a small container, and a large container can of course put a small container)

span and label
Since the above statement about span, then we can perform a span container operation on the text, we can define CSS styles or something, but label seems to be fine too? But what is the difference between the two?
The label tag is mainly used to bind a form element, and when the label tag is clicked, the bound form element will get the input focus
span is a kind of container for ordinary text.




Previous:Java script to get cookies for the current website login!
Next:[Super Dick] is the masterpiece of folk AE special effects technology
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com