What is the theoretical explanation of
<span></span>
tag? And where we use? What is the use of this tag?
What is the theoretical explanation of
<span></span>
tag? And where we use? What is the use of this tag?
From here:
Definition and Usage
The tag provides no visual change by itself.
The tag provides a way to add a hook to a part of a text or a part of a document.
When the text is hooked in a span element you can add styles to the content, or manipulate the content with for example JavaScript.
So, the short version is, it's to style some text (without a paragraph or linebreak which is different from <div> tag)
It's just a way to logically group subelements together. You can also apply styles, etc at this level which will cascade down.
Take a look at the wikipedia article which goes into some depth.
It is for grouping HTML elements and content for applying structure, defined for HTML 4.0 at http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.4:
The DIV and SPAN elements, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. These elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content. Thus, authors may use these elements in conjunction with style sheets, the lang attribute, etc., to tailor HTML to their own needs and tastes.
It goes on to give an example of the usage.
Span has no structural meaning to the document (as h1 does, for instance), but can be used as a container when none of the other inline containers are appropiate. You would, for instance, use a span if you needed to apply some CSS to a small bit of text within some other text.
Hi
The span tag just tells the browser to apply what ever style changes are included within the span and if there is no styling within the span then there would be no formatting applied to the enclosed text. This is a bit different from the div tag which incorporates a paragraph break even if no styling options are included within a div.
So it is useful when you want to apply styles to elements without placing them in a separate block.
cheers
It's just a placeholder for javascript or css.
If you don't use javascript/css, has no use to u.