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