Jit*_*yas 53 css xhtml w3c web-standards
这是正确使用的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>
Run Code Online (Sandbox Code Playgroud)
是使用Blockquote
, q
语义正确吗?或两者都是表现元素,所以不应该使用?
Jos*_*Lee 49
是.它们不是表示元素 - blockquote
表示块引用,q
表示内联引用,cite
表示对名称,工作,标准,URL等的引用.
你确实有一些与blockquote相当常见的验证错误.blockquote元素不能在段落中,并且在HTML4中实际上需要包含段落.需要颠倒片段中元素p
和blockquote
元素的嵌套.
所述blockquote
元件(也是q
元件)可任选地具有cite
指定URI,其中引用的来源属性.HTML5表示用户代理应该将该链接提供给用户,而HTML4根本没有说什么.我会在cite
属性和内联链接中包含URI ,因为浏览器不会处理它.
以下是我将如何编写该片段,并考虑到这些修订:
<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>
Run Code Online (Sandbox Code Playgroud)
Chu*_*utt 13
此页面上的其他答案已过期,但问题仍然有效.
的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>
Run Code Online (Sandbox Code Playgroud)
另一个例子:
<p>
<q>This is correct, said Hillary.</q> is a quote from the
popular daytime TV drama <cite>When Ian became Hillary</cite>.
</p>
Run Code Online (Sandbox Code Playgroud)
该q
元素不应该被放在一个blockquote
要素,因为它是多余的-两者都表示报价.
A blockquote
是块元素,允许其他块元素放在内部:
<blockquote>
<p>My favorite book is <cite>At Swim-Two-Birds</cite>.</p>
- <cite>Mike Smith</cite>
</blockquote>
Run Code Online (Sandbox Code Playgroud)
<cite>
稍微复杂一些.它是一个内联元素,但它取决于您遵循的HTML规范.在W3C说,它可能包含一个URL,一个工作(如书名,电影标题等)的标题,或作者姓名.
在WHATWG说,它可能只包含一个URL或作品的标题,所以不是一个人的名字.
这是一个有效的WHATWG用法:
<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>
Run Code Online (Sandbox Code Playgroud)
您可以考虑BLOCKQUOTE
类似于 aDIV
和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>
Run Code Online (Sandbox Code Playgroud)
Cite 是任何一个的属性,它仅指向源。