Integrating SPAN Element in the HTML

Posted On
September 4, 2008 by Arpish
Language:

The SPAN element was introduced into HTML to allow authors to give style that could not be attached to a structural HTML element. SPAN may be used as a selector in a style sheet, and it also accepts the STYLE, CLASS and ID attributes.

SPAN is an inline element, so it may be used just as elements such as EM and STRONG in HTML. The important distinction is that while EM and STRONG carry structural meaning, SPAN has no such meaning. It exists purely to apply style and so has no effect when the style sheet is disabled. Here are some examples of SPAN:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD> <TITLE>Example of SPAN</TITLE> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <STYLE TYPE="text/css" MEDIA="screen, print, projection"> <!-- .firstwords { font-variant: small-caps }--> </STYLE> </HEAD> <BODY> <P> <SPAN CLASS=firstwords>The first few words</SPAN> of aparagraph could be in small-caps. Style may also be inlined, such as to change the style of a word like <SPAN STYLE="font-family: Arial">Arial</SPAN>.</P>