Click to return to home page
Richard Lowe Jr Home

<SPAN> and </SPAN>

Description Attributes Examples

Description:

The <SPAN> tag is used to modify the characteristics of a particular section of text. 

The difference between <DIV> and <SPAN> is that <SPAN> is used within a paragraph, sentence or even word, while <DIV> is intended for block-level formatting.

<SPAN> is great to use with dynamic HTML, as it divides a page into sections which can be manipulated. You reference the <SPAN>'s by using their name, specified by the ID.

Attributes:

class=class

Indicates that the <SPAN> is to be formatted using the specified class.

dir=direction

Indicates the direction (right or left) that the text is to be displayed. Useful for languages which display left to right.

event=JavaScript

When event occurs, execute the specified JavaScript.

id = "name"

You can give a <SPAN> a name, which allows it to be referenced and changed in a script (dynamic HTML).

lang="lang"

Indicates the language of the text within the <SPAN>.

nowrap

Prevents the browser from wrapping except if there is an explicit <BR>.

style="style"

Defines the style in which the <SPAN> will be displayed. This overrides any style elements at an "outer" level, such as from the BODY or the Cascading Style Sheet.

title="title"

You can give a <SPAN> a title if you want. This provides some additional information about the paragraph. I'm not sure why you would want to do this, but you could.

Examples:

This examine demonstrates how SPAM can be used to modify sections of text<BR>
<SPAN style="color: purple">Purple text</SPAN>
<SPAN style="font-size: 8pt">8 point font</SPAN><P>
Testing <SPAN style="color: red">See the color changes
<SPAN style="font-size: 20pt"> and now the size changes</SPAN>
and now the size changes back</SPAN>

This examine demonstrates how SPAM can be used to modify sections of text
Purple text 8 point font

Testing See the color changes and now the size changes and now the size changes back


Unless otherwise noted, all photos and text is Copyright © Richard G Lowe, Jr.