The <SPAN> element is used to apply a style to text which doesn't play any structural role, or where use of standard HTML elements is not desirable. For example, it may be useful for text to be highlighted by rendering it with a different background colour. For text such as this, using a standard HTML element such as <EM> with an applied style, would possibly be inappropriate, because browsers that donÆt support style sheets would render the text as italicised. The <SPAN> element is recommended in such situations as other browsers simply ignore it.

The <SPAN> element can be used within text blocks to apply a style as defined in a style sheet, according to a CLASS or ID attribute, or the STYLE can be specified within the <SPAN> attribute. As with other elements used within the <BODY> of a HTML document, <SPAN> can also have a certain style applied to it in the style sheet definition.

e.g. If

.redtext : { color : #FF0000}

has been defined in a style sheet, then the following :

some text<SPAN CLASS="redtext"> some red text</SPAN> some more text
would render the some red text section in red.
<SPAN STYLE="color : #FF0000">some red text</SPAN>
would do exactly the same

See the Style Sheets topic for more information about style sheets.

Viewing the source of any page of this reference may also provide some clues. The <SPAN> element is used quite extensively for setting the styles of various text.


<SPACER> Block Formatting Elements Overview <WBR>