HTML Span Tag
HTML Span Tag
HTML Span Tag
-
The <span> element is an inline element.
-
An inline element does not start on a new line and only takes up as much width as necessary.
-
Example of inline element: <i>,<a>,<b> etc.
-
HTML Span Tag tag does not give any special appearance on web page like <b> tag, <i> tag etc gives. It generally used as a container for HTML elements.
-
Like if we want to change the color of 4 words together then we can use a <span> tag to cover all text in one.
Example:
Some words of <span style="color:blue">this sentence become</span> blue.
Difference between the Div and Span Tag
-
Div Tag takes the full width of the screen and Span Tag takes only as much as required to cover the content
Example
Some words of <span style="color:blue">this sentence become</span> blue.
Some words of <div style="color:blue">this sentence become</div> blue.
Example:
Some words of <span style="background-color:lime">this sentence become</span> blue.
Some words of <div style="background-color:lime">this sentence become</div> blue.