Is this the correct use of Blockquote
, q
and cite
?
<p>
<blockquote>Type HTML in the textarea above, <q>and it will magically appear</q> in the frame below.
</blockquote>
<cite><a href="http://stackoverflow.com">refrence url</a>
</p>
Is use of Blockquote
, q
semantically correct? or both are presentational element , so should not be used?
You could consider
BLOCKQUOTE
analogous to aDIV
andQ
analogous toSPAN
.Recommended usage is to enclose large quotes in
BLOCKQUOTE
and small, single line or sentence quotes inQ
.Cite is an attribute on either which merely points to the source.
According to this, "cite" is an attribute of q - and is not well supported at that.
The other answers on this page are out of date, but the question is still valid.
The
q
element is an inline element and should be used like so (ie. no block elements inside it):Another example:
The
q
element should not be placed inside ablockquote
element, as it would be redundant -- both denote a quote.A
blockquote
is a block element, allowing other block elements to be placed inside:<cite>
is slightly more complicated. It's an inline element but it depends which HTML spec you're following. The W3C states that it may contain a URL, a title of a work (eg. book title, film title, etc.), or an author's name.The WHATWG states that it may only contain a URL or a title of a work, and so not a person's name.
This is a valid WHATWG usage:
http://www.w3.org/TR/html401/struct/text.html#edef-BLOCKQUOTE
The semantic (and valid) use of the
<cite>
element is still under debate even if "in HTML5, use of this element to mark a person's name is no longer considered semantically appropriate."You'll find a very detailed and useful article about "
<blockquote>
,<q>
and<cite>
" here:http://html5doctor.com/blockquote-q-cite/
Yes. They are not presentational elements —
blockquote
represents a block quotation,q
represents an inline quotation, andcite
represents a reference to a name, work, standard, URL, etc.You do have some validation errors that are fairly common with blockquote. A blockquote element cannot be inside a paragraph, and in HTML4 actually needs to contain paragraphs. The nesting of the
p
andblockquote
elements in your fragment needs to be reversed.The
blockquote
element (also theq
element) can optionally have acite
attribute to specify a URI where the quote came from. HTML5 says user agents should make that link available to the user, and HTML4 doesn't say anything at all. I would include the URI both in thecite
attribute and as an inline link, since browsers don't handle it.Here's how I would write that fragment, with those revisions in mind:
Validate this fragment