span Element


 

Module

The span element is an inline element declared by the XHTML 1.1 Text Module (Inline Structural)

Elements in the Text Module are:
span | br (Inline Structural Support Module)
em | strong | q | cite | abbr | acronym | code | var | kbd | samp | dfn (Inline Phrasal Support Module)
div | p (Block Structural Support Module)
h1 - h6 | blockquote | pre | address (Block Phrasal Support Module)

Description

The span element is used as a general inline container, where content can be grouped without there being any intrinsic significance to the tag. Attributes of the span element can be used to assign a class or id (for reference within a style sheet or script) or to add a title. Another useful attribute is xml:lang, which allows a particular language to be associated with the content of the span.

For example: if, for stylistic reasons you wanted the name of your business to appear in dark red, bold-faced text throughout your site, you could enclose each occurrence of the name within a span element with a class attribute of, say, "us" and then use the CSS style rule: span.us { font-weight:bold; color:#900 } to achieve the desired effect. Like so:

<p>Here at <span class="us">Hippopotamus Enterprises</span>, 
we have a fun and relaxed, yet conscientious attitude to our work,
which is why we know you'll find that <span class="us">Hippopotamus Enterprises</span>
organise the best corporate parties in the world.</p>

With the style rule above, this example renders as:

Here at Hippopotamus Enterprises, we have a fun and relaxed, yet conscientious attitude to our work, which is why we know you'll find that Hippopotamus Enterprises organise the best corporate parties in the world.

The content of a span needn't be just text - other inline elements may be enclosed, such as a, img, em and so on - see the Content Model for span.

See also the div element, which is the block level equivalent of span.

#REQUIRED Attributes

There are no #REQUIRED attributes on the span element.


Specific Attributes

There are no specific attributes declared on the span element.


Common Attributes

Common attributes of the span element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the span element is:

( #PCDATA | Inline.mix )*

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of span

Valid parents of span


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > span Element