<span> tag

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>

Example

<h2>TutorialBrain provides <span style="color:Blue">HTML</span> Tutorial</h2>

How Browser will display

INLINE.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
None None None

Attributes used with <span> tag

NONE

Global Attributes

The <span> tag supports Global attributes.

Event Attributes

The <span> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

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.

Tutorials for all brains!