p elementHTMLElement.
The p element represents a paragraph.
The following examples are conforming HTML fragments:
<p>The little kitten gently seated himself on a piece of carpet. Later in his life, this would be referred to as the time the cat sat on the mat.</p>
<fieldset> <legend>Personal information</legend> <p> <label>Name: <input name="n"></label> <label><input name="anon" type="checkbox"> Hide from other users</label> </p> <p><label>Address: <textarea name="a"></textarea></label></p> </fieldset>
<p>There was once an example from Femley,<br> Whose markup was of dubious quality.<br> The validator complained,<br> So the author was pained,<br> To move the error from the markup to the rhyming.</p>
The p element should not be used when a
more specific element is more appropriate.
The following example is technically correct:
<section> <!-- ... --> <p>Last modified: 2001-04-23</p> <p>Author: fred@example.com</p> </section>
However, it would be better marked-up as:
<section> <!-- ... --> <footer>Last modified: 2001-04-23</footer> <address>Author: fred@example.com</address> </section>
Or:
<section> <!-- ... --> <footer> <p>Last modified: 2001-04-23</p> <address>Author: fred@example.com</address> </footer> </section>
hr elementHTMLElement.
The hr element represents a paragraph-level thematic break, e.g. a scene change
in a story, or a transition to another topic within a section of a
reference book.
br elementHTMLElement.
The br element represents a line break.
br elements must be empty. Any content
inside br elements must not be considered
part of the surrounding text.
br elements must be used only for line
breaks that are actually part of the content, as in poems or addresses.
The following example is correct usage of the br element:
<p>P. Sherman<br> 42 Wallaby Way<br> Sydney</p>
br elements must not be used for
separating thematic groups in a paragraph.
The following examples are non-conforming, as they abuse the br element:
<p><a ...>34 comments.</a><br> <a ...>Add a comment.<a></p>
<p>Name: <input name="name"><br> Address: <input name="address"></p>
Here are alternatives to the above, which are correct:
<p><a ...>34 comments.</a></p> <p><a ...>Add a comment.<a></p>
<p>Name: <input name="name"></p> <p>Address: <input name="address"></p>
If a paragraph consists of nothing but a single
br element, it represents a placeholder
blank line (e.g. as in a template). Such blank lines must not be used for
presentation purposes.
pre elementHTMLElement.
The pre element represents a block of
preformatted text, in which structure is represented by typographic
conventions rather than by elements.
In the HTML
serialisation, a leading newline character
immediately following the pre element
start tag is stripped.
Some examples of cases where the pre
element could be used:
To represent a block of computer code, the pre element can be used with a code element; to represent a block of computer
output the pre element can be used with a
samp element. Similarly, the kbd element can be used within a pre element to indicate text that the user is to
enter.
In the following snippet, a sample of computer code is presented.
<p>This is the <code>Panel</code> constructor:</p>
<pre><code>function Panel(element, canClose, closeHandler) {
this.element = element;
this.canClose = canClose;
this.closeHandler = function () { if (closeHandler) closeHandler() };
}</code></pre>
In the following snippet, samp and
kbd elements are mixed in the contents of
a pre element to show a session of Zork
I.
<pre><samp>You are in an open field west of a big white house with a boarded front door. There is a small mailbox here. ></samp> <kbd>open mailbox</kbd> <samp>Opening the mailbox reveals: A leaflet. ></samp></pre>
The following shows a contemporary poem that uses the pre element to preserve its unusual formatting,
which forms an intrinsic part of the poem itself.
<pre> maxling
it is with a heart
heavy
that i admit loss of a feline
so loved
a friend lost to the
unknown
(night)
~cdr 11dec07</pre>
dialog elementdt element
followed by one dd element.
HTMLElement.
The dialog element represents a
conversation.
Each part of the conversation must have an explicit talker (or speaker)
given by a dt element, and a discourse (or
quote) given by a dd element.
This example demonstrates this using an extract from Abbot and Costello's famous sketch, Who's on first:
<dialog> <dt> Costello <dd> Look, you gotta first baseman? <dt> Abbott <dd> Certainly. <dt> Costello <dd> Who's playing first? <dt> Abbott <dd> That's right. <dt> Costello <dd> When you pay off the first baseman every month, who gets the money? <dt> Abbott <dd> Every dollar of it. </dialog>
Text in a dt element in a
dialog element is implicitly the source
of the text given in the following dd
element, and the contents of the dd element
are implicitly a quote from that speaker. There is thus no need to include
cite, q,
or blockquote elements in this
markup. Indeed, a q element inside a
dd element in a conversation would actually
imply the people talking were themselves quoting another work. See the
cite, q,
and blockquote elements for other
ways to cite or quote.
blockquote elementcite
interface HTMLQuoteElement : HTMLElement {
attribute DOMString cite;
};
The HTMLQuoteElement interface is also
used by the q element.
The blockquote element represents
a section that is quoted from another source.
Content inside a blockquote must
be quoted from another source, whose URI, if it has one, should be cited
in the cite
attribute.
If the cite
attribute is present, it must be a URI (or IRI). User agents should allow
users to follow such citation links.
If a blockquote element is preceded or followed by a single paragraph that contains a single cite element and that is itself not preceded or followed by another blockquote element and does not itself have
a q element descendant, then, the title of
the work given by that cite element
gives the source of the quotation contained in the blockquote element.
The cite DOM
attribute must reflect the element's cite content attribte.
The best way to represent a conversation is not with the
cite and blockquote elements, but with the dialog element.
ol elementli elements.
reversed
start
interface HTMLOListElement : HTMLElement {
attribute boolean reversed;
attribute long start;
};
The ol element represents a list of
items, where the items have been intentionally ordered, such that changing
the order would change the meaning of the document.
The items of the list are the li element
child nodes of the ol element, in tree order.
The reversed
attribute is a boolean attribute. If present, it
indicates that the list is an ascending list. If the attribute is present,
the list is a descending list.
The start
attribute, if present, must be a valid integer
giving the ordinal value of the first list item.
If the start
attribute is present, user agents must parse it as an integer, in order to determine the
attribute's value. The default value, used if the attribute is missing or
if the value cannot be converted to a number according to the referenced
algorithm, is 1 if the element has no reversed attribute, and is the number of child
li elements otherwise.
The first item in the list has the ordinal value given by the ol element's start attribute, unless that li element has a value attribute with a value that can be
successfully parsed, in which case it has the ordinal value given by that
value attribute.
Each subsequent item in the list has the ordinal value given by its
value attribute, if
it has one, or, if it doesn't, the ordinal value of the previous item,
plus one if the reversed is absent, or minus one if it is
present.
The reversed
DOM attribute must reflect the value of the reversed content
attribute.
The start DOM
attribute must reflect the value of the start content attribute.
The following markup shows a list where the order matters, and where
the ol element is therefore appropriate.
Compare this list to the equivalent list in the ul section to see an example of the same items
using the ul element.
<p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>Switzerland <li>United Kingdom <li>United States <li>Norway </ol>
Note how changing the order of the list changes the meaning of the document. In the following example, changing the relative order of the first two items has changed the birthplace of the author:
<p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>United Kingdom <li>Switzerland <li>United States <li>Norway </ol>
ul elementli elements.
HTMLElement.
The ul element represents a list of
items, where the order of the items is not important — that is,
where changing the order would not materially change the meaning of the
document.
The items of the list are the li element
child nodes of the ul element.
The following markup shows a list where the order does not matter, and
where the ul element is therefore
appropriate. Compare this list to the equivalent list in the ol section to see an example of the same items
using the ol element.
<p>I have lived in the following countries:</p> <ul> <li>Norway <li>Switzerland <li>United Kingdom <li>United States </ul>
Note that changing the order of the list does not change the meaning of the document. The items in the snippet above are given in alphabetical order, but in the snippet below they are given in order of the size of their current account balance in 2007, without changing the meaning of the document whatsoever:
<p>I have lived in the following countries:</p> <ul> <li>Switzerland <li>Norway <li>United Kingdom <li>United States </ul>
li elementol elements.
ul elements.
menu elements.
menu
element: phrasing content.ol
element: value
ol element: None.
interface HTMLLIElement : HTMLElement {
attribute long value;
};
The li element represents a list item. If
its parent element is an ol, ul, or menu
element, then the element is an item of the parent element's list, as
defined for those elements. Otherwise, the list item has no defined
list-related relationship to any other li
element.
The value
attribute, if present, must be a valid integer
giving the ordinal value of the list item.
If the value
attribute is present, user agents must parse it as an integer, in order to determine the
attribute's value. If the attribute's value cannot be converted to a
number, the attribute must be treated as if it was absent. The attribute
has no default value.
The value
attribute is processed relative to the element's parent ol element (q.v.), if there is one. If there is not,
the attribute has no effect.
The value DOM
attribute must reflect the value of the value content attribute.
The following example, the top ten movies are listed (in reverse
order). Note the way the list is given a title by using a figure element and its legend.
<figure> <legend>The top 10 movies of all time</legend> <ol> <li value="10"><cite>Josie and the Pussycats</cite>, 2001</li> <li value="9"><cite lang="sh">Црна мачка, бели мачор</cite>, 1998</li> <li value="8"><cite>A Bugs Life</cite>, 1998</li> <li value="7"><cite>Toy Story</cite>, 1995</li> <li value="6"><cite>Monsters, Inc</cite>, 2001</li> <li value="5"><cite>Cars</cite>, 2006</li> <li value="4"><cite>Toy Story 2</cite>, 1999</li> <li value="3"><cite>Finding Nemo</cite>, 2003</li> <li value="2"><cite>The Incredibles</cite>, 2004</li> <li value="1"><cite>Ratatouille</cite>, 2007</li> </ol> </figure>
The markup could also be written as follows, using the reversed attribute
on the ol element:
<figure> <legend>The top 10 movies of all time</legend> <ol reversed> <li><cite>Josie and the Pussycats</cite>, 2001</li> <li><cite lang="sh">Црна мачка, бели мачор</cite>, 1998</li> <li><cite>A Bugs Life</cite>, 1998</li> <li><cite>Toy Story</cite>, 1995</li> <li><cite>Monsters, Inc</cite>, 2001</li> <li><cite>Cars</cite>, 2006</li> <li><cite>Toy Story 2</cite>, 1999</li> <li><cite>Finding Nemo</cite>, 2003</li> <li><cite>The Incredibles</cite>, 2004</li> <li><cite>Ratatouille</cite>, 2007</li> </ol> </figure>
dl elementdt elements followed by one or mode dd elements.
HTMLElement.
The dl element introduces an association
list consisting of zero or more name-value groups (a description list).
Each group must consist of one or more names (dt elements) followed by one or more values
(dd elements).
Name-value groups may be terms and definitions, metadata topics and values, or any other groups of name-value data.
The values within a group are alternatives; multiple paragraphs forming
part of the same value must all be given within the same dd element.
The order of the list of groups, and of the names and values within each group, may be significant.
If a dl element is empty, it contains no
groups.
If a dl element contains non-whitespace text nodes, or elements other than
dt and dd,
then those elements or text
nodes do not form part of any groups in that dl.
If a dl element contains only dt elements, then it consists of one group with
names but no values.
If a dl element contains only dd elements, then it consists of one group with
values but no names.
If a dl element starts with one or more
dd elements, then the first group has no
associated name.
If a dl element ends with one or more
dt elements, then the last group has no
associated value.
When a dl element doesn't
match its content model, it is often due to accidentally using dd elements in the place of dt elements and vice versa. Conformance checkers can
spot such mistakes and might be able to advise authors how to correctly
use the markup.
In the following example, one entry ("Authors") is linked to two values ("John" and "Luke").
<dl> <dt> Authors <dd> John <dd> Luke <dt> Editor <dd> Frank </dl>
In the following example, one definition is linked to two terms.
<dl> <dt lang="en-US"> <dfn>color</dfn> </dt> <dt lang="en-GB"> <dfn>colour</dfn> </dt> <dd> A sensation which (in humans) derives from the ability of the fine structure of the eye to distinguish three differently filtered analyses of a view. </dd> </dl>
The following example illustrates the use of the dl element to mark up metadata of sorts. At the end
of the example, one group has two metadata labels ("Authors" and
"Editors") and two values ("Robert Rothman" and "Daniel Jackson").
<dl> <dt> Last modified time </dt> <dd> 2004-12-23T23:33Z </dd> <dt> Recommended update interval </dt> <dd> 60s </dd> <dt> Authors </dt> <dt> Editors </dt> <dd> Robert Rothman </dd> <dd> Daniel Jackson </dd> </dl>
The following example shows the dl
element used to give a set of instructions. The order of the instructions
here is important (in the other examples, the order of the blocks was not
important).
<p>Determine the victory points as follows (use the first matching case):</p> <dl> <dt> If you have exactly five gold coins </dt> <dd> You get five victory points </dd> <dt> If you have one or more gold coins, and you have one or more silver coins </dt> <dd> You get two victory points </dd> <dt> If you have one or more silver coins </dt> <dd> You get one victory point </dd> <dt> Otherwise </dt> <dd> You get no victory points </dd> </dl>
The following snippet shows a dl element
being used as a glossary. Note the use of dfn to indicate the word being defined.
<dl> <dt><dfn>Apartment</dfn>, n.</dt> <dd>An execution context grouping one or more threads with one or more COM objects.</dd> <dt><dfn>Flat</dfn>, n.</dt> <dd>A deflated tire.</dd> <dt><dfn>Home</dfn>, n.</dt> <dd>The user's login directory.</dd> </dl>
The dl element is
inappropriate for marking up dialogue, since dialogue is ordered (each
speaker/line pair comes after the next). For an example of how to mark up
dialogue, see the dialog element.
dt elementdd or dt elements inside dl elements.
dd element inside a dialog element.
HTMLElement.
The dt element represents the term, or
name, part of a term-description group in a description list (dl element), and the talker, or speaker, part of a
talker-discourse pair in a conversation (dialog element).
The dt element itself, when
used in a dl element, does not indicate
that its contents are a term being defined, but this can be indicated
using the dfn element.
If the dt element is the child of a
dialog element, and it further contains
a time element, then that time element represents a timestamp for when the
associated discourse (dd element) was said,
and is not part of the name of the talker.
The following extract shows how an IM conversation log could be marked up.
<dialog> <dt> <time>14:22</time> egof <dd> I'm not that nerdy, I've only seen 30% of the star trek episodes <dt> <time>14:23</time> kaj <dd> if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy <dt> <time>14:23</time> egof <dd> it's unarguably <dt> <time>14:24</time> kaj <dd> you are not helping your case </dialog>
dd elementdt or dd elements inside dl elements.
dt element inside a dialog element.
HTMLElement.
The dd element represents the
description, definition, or value, part of a term-description group in a
description list (dl element), and the
discourse, or quote, part in a conversation (dialog element).