正确使用 Blockquote、q 和 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>
使用 Blockquote
、q
在语义上是否正确?或者两者都是表现元素,所以不应该使用?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
是的。它们不是表示性元素 -
blockquote
表示块引用,q
表示内联引用,cite
表示对名称、作品的引用,标准、URL 等。您确实有一些 验证错误在块引用中相当常见。 blockquote 元素不能位于段落内,而在 HTML4 中实际上需要包含段落。片段中
p
和blockquote
元素的嵌套需要颠倒。blockquote
元素(也是q
元素)可以选择具有cite
属性来指定引用来源的 URI。 HTML5 说 用户代理应该使该链接可供用户使用,而 HTML4 根本没有说明任何内容。我会将 URI 包含在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
此页面上的其他答案已过时,但问题仍然有效。
q
元素在语义上表示引用,并且是一个内联元素。它应该像这样使用(即内部没有块元素):另一个例子:
q
元素不应放置在blockquote
元素内,因为它是多余的-- 两者都表示引用。blockquote
是一个块元素,允许将其他块元素放置在内部:是一个内联元素,表示内容的 title工作主体。由于 W3C 和 WHATWG 现已同意合作,我们有 关于它可能包含的内容的一个答案:一本书、一部电影、电视节目、游戏、歌曲、戏剧等的名称。
它不应该是 URL 或作者姓名(可以使用普通
a
元素添加 URL,并且作者不是您引用的作品)。这是一个有效的用法:
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):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 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:
您可以将
BLOCKQUOTE
视为类似于DIV
,将Q
视为类似于SPAN
。建议的用法是将大引号括在
BLOCKQUOTE
中,将小单行或句子引号括在Q
中。引用是两者的一个属性,仅指向来源。
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.
使用诸如
blockquote
或q
的cite
属性之类的属性并不能让其轻松显示(没有 JS 或棘手的 CSS),而且没有达到轻松显示参考链接的目的。 现在符合包含cite
(和/或footer
) intoblockquote
来指定引用的来源(无论是文本形式还是通过 URL),如下所示:请注意:
属于引用内容(而不是来源引用)的
cite
情况也被认为非常罕见,应通过相关cite
子标签上的区分类进行处理)关于
q
,它确实旨在内联引用,但它更有可能在块引用之外使用(引用到引号中的情况很少见)。Using attributes such as the
cite
attribute of theblockquote
orq
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 includecite
(and/orfooter
) intoblockquote
to specify the source, either textually of through a URL, of the quote, like below :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 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).元素的语义(和有效)使用仍然存在争议,即使“在 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/
根据此,“引用”是以下内容的属性 q - 并没有得到很好的支持。
According to this, "cite" is an attribute of q - and is not well supported at that.