HTML - The Span Tag - Neils Resource WebHTML - The Span Tag - Neils Resource WebSpan Tag - HTML - Web Dev. - Neils Resource Web

HTML - The Span Tag - Neils Resource WebHTML - The Span Tag - Neils Resource WebSpan Tag - HTML - Web Dev. - Neils Resource Web

HTML - The Span Tag - Neils Resource WebHTML - The Span Tag - Neils Resource WebSpan Tag - HTML - Web Dev. - Neils Resource Web

Contract Menu | Expand Menu

Summary of Content
The SPAN tag is a superior HTML tag capable of adding some very useful elements to your web pages. This page is a good example of the range possible.
Try Hypergurl - an excellent reference source, loads of samples and information.

A double mouse click anywhere on the page (except when over hyperlinks) will take you back to the top.


Span Tag

The SPAN tag allows you to add attributes to blocks of text, and not necessarily complete sentences or paragraphs. As opposed to the DIV tag The SPAN tag is used more often within paragraphs or blocks of text. The main difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag just tells the browser to apply the style rules to whatever is within the <span>.

A few examples of ways you can use this tag....

Example: You can highlight your text any colour you like.

Code: <span style="background-color: #FFFF00">You can highlight your text any colour you like</span>

Example: You can add coloured text for parts of a sentence

Code: <p>You can <span style="color: red; font-size: 14pt">can add coloured text</span> for parts of a sentence.</p>

Example: You can add a background image to your text.

Code: <SPAN STYLE="background-image: url(yourimage.jpg)">You can add a background image to your text.</SPAN>

You can add what is like an "alt tag" to your text.
Try the example below and hover your mouse over the text. (Netscape)

Example: Hover your mouse pointer over this sentence to display an alt tag.

The span tag is useful for defining text and image MouseOvers.
Run your mouse cursor over the text or image below.

Example: This is an example of changing the colour of text using a MouseOver.

Code:  onmouseout="this.style.color = 'black';" onmouseover="this.style.color = 'red';"

Left Arrow

Code: <SPAN onMouseOver="document.pic1.src='yourimage.gif'" onMouseOut="document.pic1.src='yourimage.gif'"><img src="yourimage.gif" height="40" width="100" name="pic1"></SPAN>

wwwThis Site

Last Update: 04/03/2008 - HTML - Notes on the Span Tag - Neils Resource Web

html 4.01 strict css 2.1 javascript 1.2