正确使用 Blockquote、q 和 cite?

发布于 2024-08-20 12:22:56 字数 417 浏览 10 评论 0原文

这是 Blockquoteqcite 的正确用法吗?

<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>

使用 Blockquoteq 在语义上是否正确?或者两者都是表现元素,所以不应该使用?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

风筝在阴天搁浅。 2024-08-27 12:22:56

是的。它们不是表示性元素 - blockquote 表示块引用,q 表示内联引用,cite 表示对名称、作品的引用,标准、URL 等。

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

blockquote 元素(也是 q 元素)可以选择具有 cite 属性来指定引用来源的 URI。 HTML5 说 用户代理应该使该链接可供用户使用,而 HTML4 根本没有说明任何内容。我会将 URI 包含在 cite 属性中并作为内联链接,因为浏览器不处理它。

以下是我编写该片段的方式,并考虑到这些修订:

<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>

验证此片段

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.

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 and blockquote elements in your fragment needs to be reversed.

The blockquote element (also the q element) can optionally have a cite 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 the cite 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:

<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

女皇必胜 2024-08-27 12:22:56

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

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>

另一个例子:

<p>
    <q>This is correct, said Hillary.</q> is a quote from the 
    popular daytime TV drama <cite>When Ian became Hillary</cite>.
</p> 

q 元素不应放置在 blockquote 元素内,因为它是多余的-- 两者都表示引用。

blockquote 是一个块元素,允许将其他块元素放置在内部:

  <blockquote>
    <p>My favorite book is <cite>At Swim-Two-Birds</cite>.</p>
    - <cite>Mike Smith</cite>
  </blockquote>

是一个内联元素,表示内容的 title工作主体。由于 W3C 和 WHATWG 现已同意合作,我们有 关于它可能包含的内容的一个答案:一本书、一部电影、电视节目、游戏、歌曲、戏剧等的名称。

它不应该是 URL 或作者姓名(可以使用普通 a 元素添加 URL,并且作者不是您引用的作品)。

这是一个有效的用法:

<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>

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):

<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.

A blockquote is a block element, allowing other block elements to be placed inside:

  <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 title of a body of work. Since the W3C and WHATWG have now agreed to work together, we have one answer as 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 (a URL can be added with a normal a element and an author is not a piece of work that you're citing).

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>
人海汹涌 2024-08-27 12:22:56

您可以将 BLOCKQUOTE 视为类似于 DIV,将 Q 视为类似于 SPAN

建议的用法是将大引号括在 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>

引用是两者的一个属性,仅指向来源。

You could consider BLOCKQUOTE analogous to a DIV and Q analogous to SPAN.

Recommended usage is to enclose large quotes in BLOCKQUOTE and small, single line or sentence quotes in 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.

靑春怀旧 2024-08-27 12:22:56

使用诸如 blockquoteqcite 属性之类的属性并不能让其轻松显示(没有 JS 或棘手的 CSS),而且没有达到轻松显示参考链接的目的。 现在符合包含cite(和/或 footer) into blockquote 来指定引用的来源(无论是文本形式还是通过 URL),如下所示:

<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>

请注意:

  • 属于引用内容(而不是来源引用)的 cite 情况也被认为非常罕见,应通过相关 cite 子标签上的区分类进行处理)

  • 关于q,它确实旨在内联引用,但它更有可能在块引用之外使用(引用到引号中的情况很少见)。

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 conforming to include cite (and/or footer) into blockquote to specify the source, either textually of through a URL, of the quote, like below :

<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 handled through a differenciating class on the relevant cite 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).

于我来说 2024-08-27 12:22:56

元素的语义(和有效)使用仍然存在争议,即使“在 HTML5 中,使用此元素来标记人名不再被认为在语义上是适当的。 “

您会发现一篇关于“

的非常详细且有用的文章代码>”此处:

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

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/

定格我的天空 2024-08-27 12:22:56

根据,“引用”是以下内容的属性 q - 并没有得到很好的支持。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文