2011-06-17 28 views
12

顯示HTML5 blockquote的正確方法是什麼?正確的HTML Blockquote

我有以下幾點:

<blockquote> 
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> 
    <cite>John Doe<br/>ACME Industries</cite> 
</blockquote> 

但我不知道這是否是正確的放置舉裏面的塊引用,並會想appropiately風格,但如果我將它移出報價我會需要用div來包裝它以賦予獨特的樣式屬性。思考?謝謝

也根據:http://dev.w3.org/html5/spec/Overview.html#the-cite-element我應該使用<b>標籤的名稱?

這是正確的嗎?

<div class="testimonial"> 
    <blockquote> 
     <p>The team worked closely with us to define our requirements, delivering the project over agreed phases to time and on budget</p> 
    </blockquote> 
    <p><b>John Doe</b><br />ACME Industries</p> 
</div> 
+0

您可以將引用內的blockquote標籤本身作爲屬性。只需將其附加到blockquote標記(引用=「whatever.com」)。 – iamandrus

+0

以下是備份Itamake關於引用作爲屬性的評論的網址http://www.w3.org/TR/html-markup/blockquote.html http://www.w3schools.com/html5/tag_blockquote.asp但是你不要沒有可以引用的URL。 – mrk

+0

您應該閱讀http://wiki.whatwg.org/wiki/Cite_element – Knu

回答

21

基於recent changes in the HTML specifications,這是現在正確的方式來處理塊引用。

<blockquote> 
    <p>Measuring programming progress by lines of code is like measuring aircraft building progress by weight.</p> 
    <footer> 
     — <cite><a href="http://www.thegatesnotes.com">Bill Gates</a></cite> 
    </footer> 
</blockquote> 
+1

這應該是答案 –

+1

我可以對其進行誤讀,但規範似乎認爲引用應該位於頁腳*或*引用元素內,而不是頁腳元素內的引用元素。 –

+1

@MrFett [spec](http://www.w3.org/html/wg/drafts/html/master/grouping-content.html#the-blockquote-element)實際上對「footer」加上有點矛盾'引用',但進一步下來他們有一個完全如同答案中的例子。 – mb21

0

語義以下是有道理的,使用blockquote元素內引用屬性來舉一個具體的網址,並結束塊引用標記之前的cite元素(內置),像這樣:

<div> 
<blockquote cite="http://example.com"> 
<p>The quick brown fox jumps over the lazy dog</p> 
<cite>Illustrative Shorthand</cite> by Linda Bronson (1888) 
</blockquote> 
</div> 

快速的棕色狐狸跳過懶惰的狗。

說明性的速記琳達·布朗森

記住,塊引用是長期的報價,所以雖然上面在技術上是正確的,更好的方式是:

<div> 
<q>The quick brown fox jumps over the lazy dog</q> 
<cite>Illustrative Shorthand</cite> by Linda Bronson (1888) 
</div> 

「敏捷的棕色狐狸跳過了懶狗「 Linga Bronson的示例速記

如果你想強調作者的名字,你可以使用b。請注意,引用用於本書的名稱,在本例中爲說明性速記。

+1

但是,爲什麼會在'blockquote'內引用?因爲所引用的文字不是引用文字... – Cameron

4

我認爲你的第二種形式比你的第一種形式要好。我認爲報價的歸屬不應該在<blockquote>之內。

<b>標籤的使用取決於您,它可能在技術上符合規範,但它在語義上無法用於所有實際目的。

另一方面,<br/>看起來不對,似乎很難證明在那裏需要語義換行符。如果你想在單獨的行上顯示名稱和組織,那麼這是表示性的,應該用CSS來完成。

關於是否不使用<cite>元素,每個HTML5規範都不正確,但請參閱Jeremy Keith的http://24ways.org/2009/incite-a-riot,以獲取其他觀點。

這是非常主觀的,但我可能會做這樣的事情

<figure class="testimonial"> 
    <blockquote> 
     <p>The team worked closely with us to define our requirements, delivering the project over agreed phases to time and on budget</p> 
    </blockquote> 
    <figcaption class="attribution"> 
     <span class="name">John Doe</span> <span class="organisation">ACME Industries</span> 
    </figcaption> 
</figure> 
+0

您是否查看了下面的dallen的答案? http://stackoverflow.com/a/19862672/29182 – Ziggy

+0

@Ziggy - 謝謝,是的。我甚至[一直在討論](http://html5doctor.com/cite-and-blockquote-reloaded/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+HTML5DoctorComments+%28Comments+for+HTML5+Doctor%29#comment -38766)與spec編輯器。 – Alohci

-1

署名的報價,如果有的話,一定要放在blockquote元素之外。

- W3C HTML工作組

的W3C提供了一系列的不同的方法來屬性塊報價在this draft例子。您也可以閱讀this blog article,這是我在來這裏之前閱讀的。下面的例子是基於他們的建議:

<blockquote> 
<p>Attribution for the quotation, if any, must be placed outside the blockquote element.</p> 
</blockquote> 
<p>— W3C HTML Working Group</p> 

他們繼續在完全相同@Alohci使用它above方式使用<figure><figcaption>來舉個例子。

+1

這不再是這種情況。 http://html5doctor.com/cite-and-blockquote-reloaded/ – dallen

+1

我的答案已過時,請參閱達倫的答案http://stackoverflow.com/a/19862672/29182 – Ziggy