HTML <span> tag
The <span> tag acts as a container for the inline elements and contents.
It is generally used to change a part of the text. You can also apply CSS on the <span> tag.
Some website designers confuse this tag with the <div> tag.
The <div> tag is Block level while the <span> tag displays as Inline.
Syntax:
<span>text…</span>
How Browser will display
INLINE.
Difference between HTML4.01, XHTML and HTML5
HTML4 | XHTML | HTML5 |
---|---|---|
None | None | None |
Attributes used with <span> tag
NONE
Note/Warning/Danger/Info <span> tag does do anything by itself. It is basically used for purposes like changing the color of the part of text text formatting of part of text to make it bold, italic etc increasing font-size of part of the text. running scripts on the part of the text Adding a different language to only a selected part of text Adding other generic style properties
Global Attributes
The <span> tag supports Global attributes.
Event Attributes
The <span> tag supports Event attributes.
Supporting Browsers
Related Tags
Although, there are no related tags but it can be compared to <div>. Both these elements does not do anything independently but they are meaningful only when style is applied on them.
<div> – Block Level.
<span> – Inline to the text.