This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

span

Summary

Groups inline elements in a document. The span element is both style and semantics neutral; it does not assign any style attributes or semantic meaning on its own.

Overview Table

DOM Interface
HTMLSpanElement

Examples

This example uses the span element to create an inline text container that changes the color of a word to blue.

<p>This paragraph contains a single <span style="color: blue">blue</span> word.

This example uses the span element to add a simple Microformats2 h-card to a person’s name.

<span class="h-card vcard">Pius Uzamere</span>

Notes

Remarks

The SPAN element is especially useful for applying cascading style sheets (CSS) styles.

History

The span element was not initially part of HTML.

On July 3, 1995, Benjamin C. W. Sittler proposes a generic text container tag <text> for applying styles to certain blocks of text. The rendering is neutral except if used in conjunction of a stylesheet. There is a debate around <c> versus <text> about readability, meaning. Bert Bos is mentioning the extensibility nature of the <text> element through the class attribute (with values such as city, person, date, etc.). Paul Prescod is worried that both elements will be abused. He is opposed to text mentionning that “any new element should be on an old one” and adding “If we create a tag with no semantics it can be used anywehere without ever being wrong. We must force authors to properly tag the semantics of their document. We must force editor vendors to make that choice explicit in their interfaces.”

<span> has been introduced to html through the internationalization WG on September 25, 1995 in the second draft html-i18n. The purpose was to create a generic container needed to carry the lang and bidi attributes in cases where no other element is appropriate.

The first draft of html-style had the <c> element in its table of content with the purpose of applying a style to some text which doesn’t have a structural role. Michael J Hannah on December 5, 1995 proposes to get rid of the new HTML element <c> to use the new element part of the internationalization proposal draft-ietf-html-i18n because it will be able to carry the style attribute. Then in the 23 January 1996 version of the html-style it has been replaced by the <span> element.

But we had to wait until HTML 4.01 to see the new element be part of the HTML language. It appears on the HTML 4 W3C Working Draft on September 17, 1997.

Related specifications

HTML 5.1
W3C Working Draft
HTML 5
W3C Recommendation
HTML 4.01
W3C Recommendation

See also

Related articles

HTML

Attributions