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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:31:53  来源:igfitidea点击:

Correct use of Blockquote, q and cite?

cssxhtmlw3cweb-standards

提问by Jitendra Vyas

Is this the correct use of Blockquote, qand 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, qsemantically correct? or both are presentational element , so should not be used?

使用Blockquote, q语义正确吗?或者两者都是表现元素,所以不应该使用?

采纳答案by Josh Lee

Yes. They are not presentational elements — blockquoterepresents a block quotation, qrepresents an inline quotation, and citerepresents 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 pand blockquoteelements in your fragment needs to be reversed.

您确实有一些验证错误,这些错误在 blockquote 中很常见。blockquote 元素不能在段落内,而在 HTML4 中实际上需要包含段落。片段中pblockquote元素的嵌套需要颠倒。

The blockquoteelement (also the qelement) can optionally have a citeattribute 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 citeattribute 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>

Validate this fragment

验证这个片段

回答by Chuck Le Butt

The other answers on this page are out of date, but the question is still valid.

此页面上的其他答案已过时,但问题仍然有效。

The qelement 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 qelement should not be placed inside a blockquoteelement, as it would be redundant -- both denote a quote.

q元素不应该被放在一个blockquote要素,因为它是多余的-两者都表示报价。

A blockquoteis 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 BLOCKQUOTEanalogous to a DIVand Qanalogous to SPAN.

您可以考虑BLOCKQUOTE类似于 aDIVQ类似于SPAN

Recommended usage is to enclose large quotes in BLOCKQUOTEand 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 citeattribute of the blockquoteor qdoesn'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) intoblockquoteto specify the source, either textually of through a URL, of the quote, like below :

使用诸如or的cite属性之类的属性不会使其易于显示(没有 JS 或棘手的 CSS),因此无法轻松实现显示参考链接的目的。它现在符合包含(和/或)以文本方式或通过 URL 指定引用的来源,如下所示:blockquoteqcitefooterblockquote

<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 citethat 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 relevant citesubtag)

  • 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>”的非常详细且有用的文章:

http://html5doctor.com/blockquote-q-cite/

http://html5doctor.com/blockquote-q-cite/

回答by Traveling Tech Guy

According to this, "cite" is an attributeof q - and is not well supported at that.

根据,“举”是一个属性的Q -而且是没有得到很好的支持。