HTML Tags
Advertisements

HTML <span> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <span> tag is generic inline container for phrasing content, which has no default rendering or meaning. The <span> tag is extensively used to define the structural sections of a document and to layout a web page using CSS.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: Inline, and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 4, 4.01, 5

Note: The <span> is very much like a <div> element; both elements don't convey any meaning about its contents and also doesn't provide styling, or any other visual change. But <div> is a block-level element while <span> is an inline-level element.


Syntax

The basic syntax of the <span> tag is given with:

HTML / XHTML: <span> ... </span>

The example below shows the <span> tag in action.

<p>Here is some <span style="color:red;">different</span> text.</p>
<p>Read the <span class="important">Notes</span> carefully.</p>

Tip: The <span> element is the most useful inline element for associating the styles and scripts with the content (using the class or id attributes), since this element has no default rendering or meaning.


Tag-Specific Attributes

The <span> tag doesn't have any specific attribute.


Global Attributes

Like all other HTML tags, the <span> tag supports the global attributes in HTML5.


Event Attributes

The <span> tag also supports the event attributes in HTML5.


Browser Compatibility

The <span> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 3+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Layout.

Related tag: <div>.

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties