8.4. Block Elements

8.4.1. Headings

XHTML has tags to denote headings in the document at up to six different levels.

The largest and most prominent heading is h1, then h2, continuing down to h6.

The element's content is the text of the heading.

Example 8.2. h1, h2, and Other Header Tags


<h1>First section</h1>

<!-- Document introduction goes here -->

<h2>This is the heading for the first section</h2>

<!-- Content for the first section goes here -->

<h3>This is the heading for the first sub-section</h3>

<!-- Content for the first sub-section goes here -->

<h2>This is the heading for the second section</h2>

<!-- Content for the second section goes here -->

Generally, an XHTML page should have one first level heading (h1). This can contain many second level headings (h2), which can in turn contain many third level headings. Do not leave gaps in the numbering.

8.4.2. Paragraphs

XHTML supports a single paragraph element, p.

Example 8.3. p Example


<p>This is a paragraph.  It can contain just about any
  other element.</p>

8.4.3. Block Quotations

A block quotation is an extended quotation from another document that will appear in a separate paragraph.

Example 8.4. blockquote Example


<p>A small excerpt from the US Constitution:</p>

<blockquote>We the People of the United States, in Order to form
  a more perfect Union, establish Justice, insure domestic
  Tranquility, provide for the common defence, promote the general
  Welfare, and secure the Blessings of Liberty to ourselves and our
  Posterity, do ordain and establish this Constitution for the
  United States of America.</blockquote>

8.4.4. Lists

XHTML can present the user with three types of lists: ordered, unordered, and definition.

Entries in an ordered list will be numbered, while entries in an unordered list will be preceded by bullet points. Definition lists have two sections for each entry. The first section is the term being defined, and the second section is the definition.

Ordered lists are indicated by the ol element, unordered lists by the ul element, and definition lists by the dl element.

Ordered and unordered lists contain listitems, indicated by the li element. A listitem can contain textual content, or it may be further wrapped in one or more p elements.

Definition lists contain definition terms (dt) and definition descriptions (dd). A definition term can only contain inline elements. A definition description can contain other block elements.

Example 8.5. ul and ol Example


<p>An unordered list.  Listitems will probably be
  preceded by bullets.</p>

  <li>First item</li>

  <li>Second item</li>

  <li>Third item</li>

<p>An ordered list, with list items consisting of multiple
  paragraphs.  Each item (note: not each paragraph) will be

  <li><p>This is the first item.  It only has one paragraph.</p></li>

  <li><p>This is the first paragraph of the second item.</p>

    <p>This is the second paragraph of the second item.</p></li>

  <li><p>This is the first and only paragraph of the third

Example 8.6. Definition Lists with dl


  <dt>Term 1</dt>

  <dd><p>Paragraph 1 of definition 1.</p>

    <p>Paragraph 2 of definition 1.</p></dd>

  <dt>Term 2</dt>

  <dd><p>Paragraph 1 of definition 2.</p></dd>

  <dt>Term 3</dt>

  <dd><p>Paragraph 1 of definition 3.</p></dd>

8.4.5. Pre-formatted Text

Pre-formatted text is shown to the user exactly as it is in the file. Text is shown in a fixed font. Multiple spaces and line breaks are shown exactly as they are in the file.

Wrap pre-formatted text in the pre element.

Example 8.7. pre Example

For example, the pre tags could be used to mark up an email message:

<pre>  From: nik@FreeBSD.org
  To: freebsd-doc@FreeBSD.org
  Subject: New documentation available

  There is a new copy of my primer for contributors to the FreeBSD
  Documentation Project available at


  Comments appreciated.


Keep in mind that < and & still are recognized as special characters in pre-formatted text. This is why the example shown had to use &lt; instead of <. For consistency, &gt; was used in place of >, too. Watch out for the special characters that may appear in text copied from a plain-text source, like an email message or program code.

8.4.6. Tables

Mark up tabular information using the table element. A table consists of one or more table rows (tr), each containing one or more cells of table data (td). Each cell can contain other block elements, such as paragraphs or lists. It can also contain another table (this nesting can repeat indefinitely). If the cell only contains one paragraph then the pelement is not needed.

Example 8.8. Simple Use of table


<p>This is a simple 2x2 table.</p>

    <td>Top left cell</td>

    <td>Top right cell</td>

    <td>Bottom left cell</td>

    <td>Bottom right cell</td>

A cell can span multiple rows and columns by adding the rowspan or colspan attributes with values for the number of rows or columns to be spanned.

Example 8.9. Using rowspan


<p>One tall thin cell on the left, two short cells next to
  it on the right.</p>

    <td rowspan="2">Long and thin</td>

    <td>Top cell</td>

    <td>Bottom cell</td>

Example 8.10. Using colspan


<p>One long cell on top, two short cells below it.</p>

    <td colspan="2">Top cell</td>

    <td>Bottom left cell</td>

    <td>Bottom right cell</td>

Example 8.11. Using rowspan and colspan Together


<p>On a 3x3 grid, the top left block is a 2x2 set of
  cells merged into one.  The other cells are normal.</p>

    <td colspan="2" rowspan="2">Top left large cell</td>

    <td>Top right cell</td>

    <!-- Because the large cell on the left merges into
         this row, the first <td> will occur on its
         right -->

    <td>Middle right cell</td>

    <td>Bottom left cell</td>

    <td>Bottom middle cell</td>

    <td>Bottom right cell</td>

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.