8. XHTML Text Module

Contents

This section is normative.

This module defines all of the basic text container elements, attributes, and their content model:

Element Attributes Minimal Content Model
abbr Common (PCDATA | Inline)*
acronym Common (PCDATA | Inline)*
address Common (PCDATA | Inline)*
blockquote Common, cite (URI) (PCDATA | Heading | Block | List)*
br Core EMPTY
cite Common (PCDATA | Inline)*
code Common (PCDATA | Inline)*
dfn Common (PCDATA | Inline)*
div Common (PCDATA | Flow)*
em Common (PCDATA | Inline)*
h Common (PCDATA | Inline)*
h1 Common (PCDATA | Inline)*
h2 Common (PCDATA | Inline)*
h3 Common (PCDATA | Inline)*
h4 Common (PCDATA | Inline)*
h5 Common (PCDATA | Inline)*
h6 Common (PCDATA | Inline)*
kbd Common (PCDATA | Inline)*
line Common (PCDATA | Inline)*
p Common (PCDATA | Inline | List | blockquote | pre | table)*
pre Common (PCDATA | Inline)*
quote Common, cite (URI) (PCDATA | Inline)*
samp Common (PCDATA | Inline)*
section Common (PCDATA | Flow)*
span Common (PCDATA | Inline)*
strong Common (PCDATA | Inline)*
var Common (PCDATA | Inline)*

The minimal content model for this module defines some content sets:

Heading
h | h1 | h2 | h3 | h4 | h5 | h6
Block
address | blockquote | div | p | pre
Inline
abbr | acronym | br | cite | code | dfn | em | kbd | q | samp | span | strong | var
Flow
Heading | Block | Inline

Note that the use of the words Block and Inline here are meant to be suggestive of the role the content sets play. They are not normative with regards to presentation (in other words, a style sheet might give an element within the Block content a display property of inline).

Implementation: DTD

8.1. The abbr element

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

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

The content of the abbr and acronym elements 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.

Note that abbreviations and acronyms 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>

8.2. The acronym element

The acronym element indicates that a text fragment is an acronym (e.g., BBC, WWW, URL, etc.). Its usage is the same as the abbr element above.

While some dictionaries define an acronym to be just a word formed from the initial letters of other words, others require the acronym to be pronouncable as a word. This specification does not require the acronym element to adhere to either definition, but is only provided for author convenience.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

Examples:

  <acronym title="World Wide Web">WWW</acronym>
  <acronym xml:lang="fr" 
        title="Société Nationale des Chemins de Fer">
     SNCF
  </acronym>

8.3. The address element

The address element may be used by authors to supply contact information for a document or a major part of a document such as a form. This element often appears at the beginning or end of a document.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

For example:

<address>
<a href="mailto:webmaster@example.net">Webmaster</a>
</address>

8.4. The blockquote element

This element designates a block of quoted text.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext
cite = URI
The value of this attribute is a URI that designates a source document or message. This attribute is intended to give further information about the element's contents (e.g., the source from which a quotation was borrowed, or the reason text was inserted or deleted). User Agents should provide a means for the user to access the further information.

This example formats an excerpt from "The Two Towers", by J.R.R. Tolkien, as a blockquote.

<blockquote cite="http://www.example.com/tolkien/twotowers.html">
<p>They went in single file, running like hounds on a strong scent,
and an eager light was in their eyes. Nearly due west the broad
swath of the marching Orcs tramped its ugly slot; the sweet grass
of Rohan had been bruised and blackened as they passed.</p>
</blockquote>

8.5. The br element

The br element indicates that the current output line should be ended at this point, and a new line begun. This element is deprecated in favor of the line element.

Attributes

The Core collection
A collection of basic attributes used on all elements, including class, id, title.

Example:

<p class="poem" xml:lang="fr">
Un petit d'un petit<br/>
S'etonne aux Halles.<br/>
Un petit d'un petit,<br/>
Ah! Degres te fallent.
</p>

8.6. 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, and Hypertext
,
cite = URI
The value of this attribute is a URI that designates a source document or message. This attribute is intended to give further information about the element's contents (e.g., the source from which a quotation was borrowed, or the reason text was inserted or deleted). User Agents should provide a means for the user to access the further information.

In the following example, the cite element is used to delineate the speaker:

As <cite cite="http://www.whitehouse.gov/history/presidents/ht33.html">Harry S. Truman</cite> said,
<quote lang="en-us">The buck stops here.</quote>

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

8.7. 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, and Hypertext

Example:

The <code>code</code> element contains a fragment of computer code.

8.8. 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, 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.

8.9. The div element

The div element, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. This element defines 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, and Hypertext

For example, suppose you wish to make a presentation in XHTML, where each slide is enclosed in a separate element. You could use a div element, with a class of slide:

<body>
    <h>The meaning of life</h>
    <p>By Huntington B. Snark</p>
    <div class="slide">
        <h>What do I mean by "life"</h>
        <p>....</p>
    </div>
    <div class="slide">
        <h>What do I mean by "mean"?</h>
        ...
    </div>
    ...
</body>

8.10. 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, and Hypertext

Example:

Do <em>not</em> phone before 9 a.m.

8.11. The heading elements

A heading element briefly describes the topic of the section it introduces. Heading information may be used by user agents, for example, to construct a table of contents for a document automatically.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

There are two styles of headings in XHTML: the numbered versions h1, h2 etc., and the structured version h, which is used in combination with the section element.

There are six levels of numbered headings in XHTML with h1 as the most important and h6 as the least. The visual presentation of headers can render more important headings in larger fonts than less important ones.

Structured headings use the single h element, in combination with the section element to indicate the structure of the document, and the nesting of the sections indicate the importance of the heading.

For example:

<body>
<h>This is a top level heading</h>
<p>....</p>
<section>
    <p>....</p>
    <h>This is a second-level heading</h>
    <p>....</p>
    <h>This is another second-level heading</h>
    <p>....</p>
</section>
<section>
    <p>....</p>
    <h>This is another second-level heading</h>
    <p>....</p>
    <section>
        <h>This is a third-level heading</h>
        <p>....</p>
    </section>
</section>

These visual representation of these levels can be distinguished in a style sheet:

h {font-family: sans-serif; font-weight: bold; font-size: 200%}
section h {font-size: 150%} /* A second-level heading */
section section h {font-size: 120%} /* A third-level heading */

etc.

Numbered sections and references
XHTML does not itself cause section numbers to be generated from headings. Style sheet languages such as CSS however allow authors to control the generation of section numbers.

The practice of skipping heading levels is considered to be bad practice. The series h1 h2 h1 is acceptable, while h1 h3 h1 is not, since the heading level h2 has been skipped.

8.12. The kbd element

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

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

Example:

To exit, type <kbd>QUIT</kbd>.

8.13. The line element

The line element represents a sub-paragraph. It is intended as a structured replacement for the br element. It contains a piece of text that when visually represented should start on a new line, and have a line break at the end. Whether the line should wrap or not visually depends on styling properties of the element.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, 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:

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

the following CSS stylesheet would number each line:

.program { counter-reset: linenumber }

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

8.14. The p element

The p element represents a paragraph.

In comparison with earlier versions of HTML, where a paragraph could only contain inline text, XHTML2's paragraphs represent the conceptual idea of a paragraph, and so may contain lists, blockquotes, pre's and tables as well as inline text. They may not, however, contain directly nested p elements.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

Authors are discouraged from using empty p elements. User agents should ignore empty p.

<p>Payment options include:
<ul>
<li>cash</li>
<li>credit card</li>
<li>luncheon vouchers.</li>
</ul>
</p>

8.15. The pre element

The pre element indicates that whitespace in the enclosed text has semantic relevance, and will normally be included in renderings of the content

Note that all elements in the XHTML family preserve their whitespace in the document, which is only removed on rendering, via a stylesheet, according to the rules of CSS [CSS]. This means that in principle all elements may preserve or collapse whitespace on rendering, under control of a stylesheet. Also note that there is no requirement that the <pre> element be rendered in a monospace font (although this is the default rendering), nor that text wrapping be disabled.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

Non-visual user agents are not required to respect extra white space in the content of a pre element.

The following example shows a preformatted verse from Shelly's poem To a Skylark:

<pre>
       Higher still and higher
         From the earth thou springest
       Like a cloud of fire;
         The blue deep thou wingest,
And singing still dost soar, and soaring ever singest.
</pre>

Here is how this might be rendered:

       Higher still and higher
         From the earth thou springest
       Like a cloud of fire;
         The blue deep thou wingest,
And singing still dost soar, and soaring ever singest.

8.16. The quote element

This element designates a inline text fragment of quoted text.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext
cite = URI
The value of this attribute is a URI that designates a source document or message. This attribute is intended to give further information about the element's contents (e.g., the source from which a quotation was borrowed, or the reason text was inserted or deleted). User Agents should provide a means for the user to access the further information.

Visual user agents are not required to add delimiting quotation marks (as was the case for the q element in earlier versions of HTML). It is the responsibility of the document author to add any required quotation marks.

The following example illustrates nested quotations with the quote element.

<p>John said, <quote lang="en-us">"I saw Lucy at lunch, she told me
<quote lang="en-us">'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.w3.org/Public/www-html/June2002/001.html">We quite agree</quote>

8.17. 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, and Hypertext

Example:

On starting, you will see the prompt <samp>$ </samp>.

8.18. The section element

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, and Hypertext

The section element, in conjunction with the h element, offers a mechanism for structuring documents into sections. This element defines content to be block-level but imposes no other presentational idioms on the content, which may otherwise be controlled from a style sheet.

By representing the structure of documents explicitely using the section and h elements gives the author greater control over presentation possibilities than the traditional implicit structuring using numbered levels of headings. For instance, it is then possible to indicate the nesting of sections by causing a border to be displayed to the left of sections.

Here is an example

<body>
<h>Events</h>
<section>
    <h>Introduction</h>
    <p>....</p>
    <h>Specifying events</h>
    <p>...</p>
    <section>
        <h>Attaching events to the handler</h>
        <p>...</p>
    </section>
    <section>
        <h>Attaching events to the listener</h>
        <p>...</p>
    </section>
    <section>
        <h>Specifying the binding elsewhere</h>
        <p>...</p>
    </section>
</section>    

8.19. The span element

The span element, in conjunction with the id and class attributes, offer 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, 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>

8.20. The strong element

The strong element indicates strong emphasis for its contents.

Attributes

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

8.21. 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, and Hypertext

Example:

The parameter <var>ncols</var> represents
the number of colors to use.