9. XHTML Text Module

Contents

This section is normative.

This module defines all of the basic text container elements, attributes, and their content models that are "inline level". Note that while the concept of "inline level" can be construed as a presentation aspect, in this case it is intended to only have a semantic meaning.

Element Attributes Minimal Content Model
abbr Common (PCDATA | Text)*
cite Common (PCDATA | Text)*
code Common (PCDATA | Text)*
dfn Common (PCDATA | Text)*
em Common (PCDATA | Text)*
kbd Common (PCDATA | Text)*
l Common (PCDATA | Text)*
quote Common (PCDATA | Text)*
samp Common (PCDATA | Text)*
span Common (PCDATA | Text)*
strong Common (PCDATA | Text)*
sub Common (PCDATA | Text)*
sup Common (PCDATA | Text)*
var Common (PCDATA | Text)*

l element content model

Content model of the l element should not allow nested lines

The content model for this module defines a content set:

Text
abbr | cite | code | dfn | em | kbd | l | quote | samp | span | strong | var

Implementation: RELAX NG

9.1. The abbr element

The abbr element indicates that a text fragment is an abbreviation (e.g., W3C, XML, Inc., Ltd., Mass., etc.); this includes acronyms.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

The content of the abbr element specifies the abbreviated expression itself, as it would normally appear in running text. The title attribute of these elements may be used to provide the full or expanded form of the expression. Such a title attribute should be repeated each time the abbreviation is defined in the document.

Note that abbreviations often have idiosyncratic pronunciations. For example, while "IRS" and "BBC" are typically pronounced letter by letter, "NATO" and "UNESCO" are pronounced phonetically. Still other abbreviated forms (e.g., "URI" and "SQL") are spelled out by some people and pronounced as words by other people. When necessary, authors should use style sheets to specify the pronunciation of an abbreviated form.

Examples:
  <abbr title="Limited">Ltd.</abbr>
  <abbr title="Abbreviation">abbr.</abbr>

9.2. The cite element

The cite element contains a citation or a reference to other sources.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

In the following example, the cite element is used to reference the book from which the quotation is taken:

As <cite cite="http://www.example.com/books/the_two_towers"">Gandalf 
the White</cite> said, <quote xml:lang="en-us">The hospitality of 
your hall is somewhat lessened of late, Theoden King.</quote>

In this example, a separate specification is referenced:

More information can be found in <cite cite="http://www.w3.org/TR/REC-xml">[XML]</cite>.

9.3. The code element

The code element contains a fragment of computer code.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
The Pascal statement <code>i := 1;</code> assigns the
literal value one to the variable <var>i</var>.

9.4. The dfn element

The dfn element contains the defining instance of the enclosed term.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
An <dfn id="def-acronym">acronym</dfn> is a word formed
from the initial letters or groups of letters of words in a set phrase
or series of words.

9.5. The em element

The em element indicates emphasis for its contents.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
Do <em>not</em> phone before 9 a.m.

9.6. The kbd element

The kbd element indicates input to be entered by the user.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
To exit, type <kbd>QUIT</kbd>.

9.7. The l element

The l element represents a semantic line of text (e.g., a line of verse or a line of computer code).

When visually represented, the l element should start on a new line and have a line break at the end. Whether the line should wrap or not depends on styling properties of the element.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

By retaining structure in text that has to be broken over lines, you retain essential information about its makeup. This gives you greater freedom with styling the content. For instance, line numbers can be generated automatically from the stylesheet if needed.

For instance, for a document with the following structure:

<blockcode class="program">
<l>program p(input, output);</l>
<l>begin</l>
<l>   writeln("Hello world");</l>
<l>end.</l>
</blockcode>

the following CSS stylesheet would number each line:

.program { counter-reset: linenumber }

l:before {
    position: relative;
    left: -1em;
    counter-increment: linenumber;
    content: counter(linenumber);
}

9.8. The quote element

This element designates an inline text fragment of quoted text.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

Visual user agents must not by default add delimiting quotation marks (as was the case for the q element in earlier versions of XHTML). It is the responsibility of the document author to add any required quotation marks, either directly in the text, or via a stylesheet.

The following example illustrates nested quotations with the quote element.

<p>John said, <quote>"I saw Lucy at lunch, she told me
<quote>'Mary wants you
to get some ice cream on your way home.'</quote> I think I will get
some at Jen and Berry's, on Gloucester Road."</quote></p>

Here is an example using the cite attribute:

Steven replied:
<quote cite="http://lists.example.org/2002/01.html">We quite agree</quote>

9.9. The samp element

The samp element designates sample output from programs, scripts, etc.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
On starting, you will see the prompt <samp>$ </samp>.

9.10. The span element

The span element, in conjunction with the id and class attributes, offers a generic mechanism for adding structure to documents. This element imposes no presentational idioms on the content. Thus, authors may use this element in conjunction with style sheets, the xml:lang attribute, etc., to tailor XHTML to their own needs and tastes.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

For example, suppose you wish to mark all words in a document that need to be collected into an index. You could use a span element, with a class of xref:

<p>This operation is called
the <span class="xref">transpose</span>
or <span class="xref">inverse</span>.</p>

9.11. The strong element

The strong element indicates higher importance for its contents.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
On <strong>Monday</strong> please put the rubbish out,
but <em>not</em> before nightfall!

9.12. The sub element

The sub element indicates that its contents should regarded as a subscript.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

For visual user agents this element would normally be rendered as a subscript of the text baseline, but on user agents where this is not possible (for instance teletype-like devices) other renderings may be used. For instance, a<sub>i, j</sub> that would be rendered as ai, j on a device that can render it so, might be rendered as a[i, j] on a simpler device.

Example:
      H<sub>2</sub>O

9.13. The sup element

The sup element indicates that its contents should be regarded as a super-script.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext

For visual user agents this element would normally be rendered as a super-script of the text baseline, but on user agents where this is not possible (for instance teletype-like devices) other renderings may be used. For instance, 2<sup>n</sup> that would be rendered as 2n on a device that can render it so, might be rendered as 2↑(n) on a simpler device.

Many scripts (e.g., French) require superscripts or subscripts for proper rendering. The sub and sup elements should be used to markup text in these cases.

Examples:
      E = mc<sup>2</sup>
      <span xml:lang="fr">M<sup>lle</sup> Dupont</span>

9.14. The var element

The var element indicates an instance of a variable or program argument.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, Map, Metainformation, and Hypertext
Example:
The parameter <var>ncols</var> represents
the number of colors to use.

9.15. Issues

[XHTML2] Comments on WD 5: make white space preservation part of the standard values for the code and kbd elements? PR #6554
State: Approved
Resolution: Accepted
User: Agree

Notes:
All elements preserve space in XHTML 2, so the author has the opportunity on user agents that support CSS to specify whether that should be reflected on output. There will be an attribute that will pass this preservation on to presentation.