CSS 正确使用 Blockquote、q 和 cite?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2205159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Correct use of Blockquote, q and cite?
提问by Jitendra Vyas
Is this the correct use of Blockquote
, q
and cite
?
这是Blockquote
, q
和的正确用法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?
使用Blockquote
, q
语义正确吗?或者两者都是表现元素,所以不应该使用?
采纳答案by Josh Lee
Yes. They are not presentational elements — blockquote
represents a block quotation, q
represents an inline quotation, and cite
represents a reference to a name, work, standard, URL, etc.
是的。它们不是展示元素——blockquote
代表一个块引用,q
代表一个内嵌引用,cite
代表对名称、作品、标准、URL 等的引用。
You do have some validation errorsthat are fairly common with blockquote. A blockquote element cannot be inside a paragraph, and in HTML4 actually needs to containparagraphs. The nesting of the p
and blockquote
elements in your fragment needs to be reversed.
您确实有一些验证错误,这些错误在 blockquote 中很常见。blockquote 元素不能在段落内,而在 HTML4 中实际上需要包含段落。片段中p
和blockquote
元素的嵌套需要颠倒。
The blockquote
element (also the q
element) can optionally have a cite
attribute to specify a URI where the quote came from. HTML5 saysuser agents shouldmake that link available to the user, and HTML4 doesn't say anything at all. I would include the URI both in the cite
attribute and as an inline link, since browsers don't handle it.
所述blockquote
元件(也是q
元件)可任选地具有cite
指定URI,其中引用的来源属性。HTML5 说用户代理应该向用户提供该链接,而 HTML4 根本没有说明。我会在cite
属性和内联链接中包含 URI ,因为浏览器不处理它。
Here's how I would write that fragment, with those revisions in mind:
以下是我将如何编写该片段,并考虑到这些修订:
<blockquote cite="http://stackoverflow.com">
<p>Type HTML in the textarea above, <q>and it will magically
appear</q> in the frame below.</p>
</blockquote>
<p>
<cite><a href="http://stackoverflow.com">reference url</a></cite>
</p>
回答by Chuck Le Butt
The other answers on this page are out of date, but the question is still valid.
此页面上的其他答案已过时,但问题仍然有效。
The q
element semantically represents a quotation, and is an inline element. It should be used like so (ie. no block elements inside it):
该q
元素在语义上表示引用,并且是内联元素。它应该像这样使用(即里面没有块元素):
<p>
In the words of <cite>Charles Bukowski</cite> -
<q>An intellectual says a simple thing in a hard way.
An artist says a hard thing in a simple way.</q>
</p>
Another example:
另一个例子:
<p>
<q>This is correct, said Hillary.</q> is a quote from the
popular daytime TV drama <cite>When Ian became Hillary</cite>.
</p>
The q
element should not be placed inside a blockquote
element, as it would be redundant -- both denote a quote.
该q
元素不应该被放在一个blockquote
要素,因为它是多余的-两者都表示报价。
A blockquote
is a block element, allowing other block elements to be placed inside:
Ablockquote
是块元素,允许其他块元素放在里面:
<blockquote>
<p>My favorite book is <cite>At Swim-Two-Birds</cite>.</p>
- <cite>Mike Smith</cite>
</blockquote>
<cite>
is an inline element representing the titleof a body of work. Since the W3C and WHATWG have now agreed to work together, we have one answeras to what it may contain: The name of a book, a film, a TV show, a game, a song, a play, etc, etc. It should not be a URL or an author's name.
<cite>
是一个内联元素,表示作品主体的标题。由于 W3C 和 WHATWG 现在已经同意合作,我们对它可能包含的内容有一个答案:书名、电影名、电视节目名、游戏名、歌曲名、戏剧名等。不应是 URL 或作者姓名。
This is a valid usage:
这是一个有效的用法:
<figure>
<blockquote>
<p>The truth may be puzzling. It may take some work to grapple with.
It may be counterintuitive. It may contradict deeply held
prejudices. It may not be consonant with what we desperately want to
be true. But our preferences do not determine what's true.</p>
</blockquote>
<figcaption>Carl Sagan, in "<cite>Wonder and Skepticism</cite>", from
the <cite>Skeptical Inquirer</cite> Volume 19, Issue 1 (January-February
1995)</figcaption>
</figure>
回答by Joel
You could consider BLOCKQUOTE
analogous to a DIV
and Q
analogous to SPAN
.
您可以考虑BLOCKQUOTE
类似于 aDIV
和Q
类似于SPAN
。
Recommended usage is to enclose large quotes in BLOCKQUOTE
and small, single line or sentence quotes in Q
.
推荐的用法是将大引号BLOCKQUOTE
括在Q
.
<blockquote>
<p>This is a big quote.</p>
<p>This is the second paragraph with a smaller <q>quote</q> inside</p>
</blockquote>
Cite is an attribute on either which merely points to the source.
Cite 是两者的一个属性,它仅指向源。
回答by Javarome
Using attributes such as the cite
attribute of the blockquote
or q
doesn't make it easily displayable (without JS or tricky CSS) and so does not address the aim of displaying a reference link easily. It is now conformingto include cite
(and/or footer
) intoblockquote
to specify the source, either textually of through a URL, of the quote, like below :
使用诸如or的cite
属性之类的属性不会使其易于显示(没有 JS 或棘手的 CSS),因此无法轻松实现显示参考链接的目的。它现在符合包含(和/或)到以文本方式或通过 URL 指定引用的来源,如下所示:blockquote
q
cite
footer
blockquote
<blockquote>
<p>Beware of bugs in the above code; I have only proved it correct, not tried it.” </p>
<cite><a href="http://www-cs-faculty.stanford.edu/~uno/faq.html">Donald Knuth: Notes on the van Emde Boas construction of priority deques: An instructive use of recursion, March 29th, 1977</a>
</blockquote>
Note that :
注意 :
cases of
cite
that are part of the quote contents (not the source reference) are also deemed quite rare, and should be handle through a differenciating class on the relevantcite
subtag)Regarding
q
, it is indeed aimed to quote inline, but it is more likely to be used outside of blockquotes (quotes into quotes are quite rare).
的情况下,
cite
这是该帖的内容(而不是源参考)也被认为是相当罕见的一部分,并应通过differenciating类是把手上的相关cite
子标记)关于
q
,它确实旨在引用内联,但它更有可能在块引用之外使用(引号中的引用非常罕见)。
回答by Nico Pernice
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."
<cite>
即使“在 HTML5 中,使用这个元素来标记一个人的名字在语义上不再合适”,该元素的语义(和有效)使用仍在争论中。
You'll find a very detailed and useful article about "<blockquote>
, <q>
and <cite>
" here:
您会在此处找到有关“ <blockquote>
,<q>
和<cite>
”的非常详细且有用的文章: