q ElementThe q element is an inline element declared by the XHTML 1.1 Text Module (Inline Phrasal)
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)
The q element is used to mark up a brief, inline quotation and can be used with or without its optional
cite attribute (not to be confused with the cite
element). The contents of the q element are often, but not always, placed in quotation marks by the browser. If a longer
quotation is desired, requiring more than one paragraph, the blockquote element should be used.
Firstly, the use of q in combination with a cite element is shown in the following example:
<p>As Charmian says in <cite>Shakespeare's Antony & Cleopatra</cite>: <q>I love long life better than figs.</q></p>
which renders as follows:
As Charmian says in Shakespeare's Antony & Cleopatra: I love long life better than figs.
The q element above is not styled and so is displayed using your browser's default behaviour.
This means that if the quoted text is surrounded by quotation marks (which may vary in appearance according to language or locale)
then your browser automatically adds them and if not then it doesn't.
This behaviour is not very standard and should not be relied upon - for this reason, some avoid the use of the q element.
The cite attribute may be used to specify a
URI from which the quotation has been taken. However,
currently there are no browsers of which I am aware that recognise the
cite attribute and present the user with
an actual link to the URI. Unless something is done by the author (for example including JavaScript to
find the cite attributes and explicitly create
links to the URIs) there is no easy way for someone viewing the page to even know the citation is there.
It is probably best to acknowledge your source using a
cite element in combination with a hyperlink
(but include the cite attribute as well to explicitly link that quote to that URI -
as far as search engines are concerned, for example).
The JavaScript method is a solution, of course, but you can never guarantee that viewers of your page will have a compatible version of JavaScript
installed and enabled. Your quoted source may also insist on a conventional hyperlink as their citation.
This second example shows the use of the cite attribute to specify a
URI for the citation. This is used in combination with a
cite element and hyperlink.
<p>It says on
<cite><a href="http://en.wikipedia.org/wiki/Hippopotamus">Wikipedia's
Hippopotamus page</a></cite> that
<q cite="http://en.wikipedia.org/wiki/Hippopotamus">Hippos
spend most of their days wallowing in the water or the mud</q>.
This sounds like a very enjoyable use of time to me!</p>
This example renders as:
It says on
Wikipedia's
Hippopotamus page that
Hippos
spend most of their days wallowing in the water or the mud
.
This sounds like a very enjoyable use of time to me!
There are no #REQUIRED attributes on the q element.
q element are listed below:q element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
q element is:
( #PCDATA | Inline.mix )*
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
qabbr, acronym, br, cite, code, dfn, em, kbd, q, samp, span, strong, varabutton, input, label, select, textareaimgb, big, i, small, sub, sup, ttmapnoscript, scriptdel, insbdoobjectrubyqabbr, acronym, address, cite, code, dfn, div, em, h1 - h6, kbd, p, pre, q, samp, span, strong, varadd, dt, licaption, td, thbutton, fieldset, label, legendb, big, i, small, sub, sup, ttdel, insbdoobjectrb, rt