2011-10-16 12:05:08 阅读6 评论0 162011/10 Oct16
本章介绍的结构元素用于构建网页结构,例如,在页面中创建含有标题的区域、建立段落等等。结构元素是构建一切网页的基石。
<blockquote cite=”uri”>
</blockquote>
下例是一段引文,出处未知。
<blockquote>
<p>
It’s missing alt text, so it’s difficult to determine what it’s supposed to mean. Presumably “oooh, there’s been a global ecological catastrophe and we’ve got the last four leaves in the world and we’ve patented the DNA”. Or they’re rubbing ganja leaves together to extract the resin, but are too stupid to recognize Marijuana so are trying it with willow or silver birch.
</p>
</blockquote>
Blockquote元素用于标记一段援引自某人、某文件或某个来源的文字。这段文字可以只有几行,也可以包含几段(此时需要使用嵌套元素p)。
W3C推荐标准规定,网页作者使用blockquote时,切勿手动输入引号把引文括起来——元素呈现可以交给样式表来处理(使用q元素标记行内简短引文是也是如此)。但是,在实践中,由于浏览器不怎么支持自动插入语言中使用的引号,因此作者往往选择手工输入引号。
默认情况下,多数浏览器有内建样式表,渲染blockquote内容时进行左右缩进,参见例2.1。结果,很多人为了凸显网面上的某个段落或者区域,使用blockquote来缩进文本。这种手法未能正确使用该标记的含义,应予与杜绝。务必只在引用材料时才使用blockquote元素。如果需要缩进不是引文的文本,请使用CSS(如margin-left属性,或者其他恰当的样式属性)。
请注意,XHMTL只允许blockquote包含块级元素;而在HTML4中,可以使用script元素。
This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake.
It’s missing alt text, so it’s difficult to determine what it’s supposed to mean. Presumably “oooh, there’s been a global ecological catastrophe and we’ve got the last four leaves in the world and we’ve patented the DNA”. Or they’re rubbing ganja leaves together to extract the resin, but are too stupid to recognize Marijuana so are trying it with willow or silver birch.
This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake. This is a normal paragraph, for comparison’s sake.
例2.1:两段正常文本中间夹有blockquote元素(注意缩进)
本元素用于标记一个或者多个段落,这些段落本身也可含有行内元素(例如,strong、em或者a元素等)。
blokquote元素出现的时间相当长了,并未随着技术的发展而遭到淘汰。如果使用blockquote时没有应用任何外部样式表,只使用浏览器默认(或叫内嵌)样式表,该元素在所有浏览器中的渲染效果几乎没有区别,某些早期浏览器也不例外。不过所有浏览器都不会在页面上渲染cite属性的值。
浏览器对cite属性支持不佳,无法利用cite属性值来显示引用来源。
<…> q
用于标记行内引用。
用在blockquote中的属性
cite=”uri”
本例演示cite属性的用法:
<blockquote cite=”http://www.brucelawson.co.uk/index.php/2005/sutpid-stock-photography/”>
<p>
It’s missing alt text, so it’s difficult to determine what it’s supposed to mean. Presumably “oooh, there’s been a global ecological catastrophe and we’ve got the last four leaves in the world and we’ve patented the DNA”. Or they’re rubbing ganja leaves together to extract the resin, but are too stupid to recognize Marijuana so are trying it with willow or silver birch.
</p>
</blockquote>
和HTML中广泛使用的core和event属性一样,blockquote也有一个cite属性,用处是以URI的形式指明引用的在网络上的来源(如”http://sourcewebsite.doc/document.html”);不过cite的属性值不会显示在屏幕上。因此,浏览器对该属性的支持标为“无”。不过,该属性有其他潜在用途(如用于搜索引擎索引、通过DOM脚本提取属性值等),而且未来的浏览器也会加强对该属性的原生支持,所以,使用blockquote的同时也应该加上cite属性。
cite的属性值是一个URI:即引用来源的完整路径(不是引用页面的相对路径)。
所有浏览器都不在页面上显示cite属性,但是这是一种有潜在应用价值的元数据,通过神奇的DOM脚本可以把这一数据提取出来然后重新现实在页面上。如果不用DOM脚本来处理——或许因为使用内容管理系统按需重构了标记符号——现实引用来源的保险之道是使用cite元素,而不使用blockquote的cite属性:
<blockquote >
<p>
It’s missing alt text, so it’s difficult to determine what it’s supposed to mean. Presumably “oooh, there’s been a global ecological catastrophe and we’ve got the last four leaves in the world and we’ve patented the DNA”. Or they’re rubbing ganja leaves together to extract the resin, but are too stupid to recognize Marijuana so are trying it with willow or silver birch.
</p>
<p>
<cite>
<a href=” http://www.brucelawson.co.uk/index.php/2005/sutpid-stock-photography/” >Bruce Lawson</a>
</cite>
</p>
</blockquote>
如果用户想要看到cite属性值,火狐至少还能把信息显示出来,不过需要用户打开右键快捷菜单(或者右键点击引文)选择“属性”,就能显示出来这点形同鸡肋的信息。
翻译:倪卫国
The Ultimate HTML Reference by Ian Lloyd, Copyright ? 2008 SitePoint Pty Ltd.
非商业用途