程序员

blockquote标记应用注意

作者:admin 2021-08-15 我要评论

关于语义化,不是一句两句就能说明白的,而且现在也没有一个官方的很严格的定义。关于 blockquote 没有争议的是: 1.引用一段较长的文字 2.可以使用cite标签或者...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

关于语义化,不是一句两句就能说明白的,而且现在也没有一个官方的很严格的定义。关于<blockquote>没有争议的是:
1.引用一段较长的文字
2.可以使用cite标签或者属性
问题是<blockquote>引用的文字必须使用块级元素将他包含吗?
首先是来自W3C的解释
9.2.2 Quotations: The BLOCKQUOTE and Q elements<!ELEMENT BLOCKQUOTE - - (%block;|SCRIPT) -- long quotation --><!ATTLIST BLOCKQUOTE %attrs;
-- %coreattrs, %i18n, %events -- cite
%URI;
#IMPLIED -- URI for source document or msg -- ><!ELEMENT Q - - (%inline;)*
-- short inline quotation --><!ATTLIST Q %attrs;
-- %coreattrs, %i18n, %events -- cite
%URI;
#IMPLIED -- URI for source document or msg -- >
这两个便签指名包含的内容为引用文字. BLOCKQUOTE 用于长文字的引用(block-level content) 而 Q 用于短文字的引用(inline content) 且不允许引用的句子不完整。
这个例子的文字来自 "The Two Towers", 作者 J.R.R. Tolkien, 最为引用文字.
<BLOCKQUOTE cite="http://www.mycom.com/tolkien/twotowers.html"><P>They went in single file, running like hounds on a strong scent,and an eager light was in their eyes. Nearly due west the broad swath of the marching Orcs tramped its ugly slot; the sweet grass of Rohan had been bruised and blackened as they passed.</P></BLOCKQUOTE>
这篇文章是应用web标准进行开发,里面提到了关于一些TAGS的语义下面摘录的是<blockquote>
For longer quotations that form one or more paragraphs, the <blockquote> element should be used. CSS can then be used to style the quotation. Note that text is not allowed directly inside a <blockquote> element – it must be contained in an element, usually a <p> element.
Example:<blockquote cite="http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html"> <p>&#8220;The following sections discuss issues surrounding the structuring of text. Elements that present text (alignment elements, font elements, style sheets, etc.) are discussed elsewhere in the specification. For information about characters, please consult the section on the document character set.&#8221;</p></blockquote>
http://24ways.org/advent/transitional-vs-strict-markup
这篇文章是关于transitional-vs-strict,过渡型和标准型xhtml的区别,里面提到了内容模型的区别,有关于<blockquote>的内容,在strict中,引用的内容必须使用块级元素将其包含,通常是<p>,<div>中。
Content model differences
An element type’s content model describes what may be contained by an instance of the element type. The most important difference in content models between Transitional and Strict is that blockquote, body, and form elements may only contain block level elements. A few examples:
text and images are not allowed immediately inside the body element, and need to be contained in a block level element like p or div
input elements must not be direct descendants of a form element
text in blockquote elements must be wrapped in a block level element like p or div
所以,我认为,在strict型必须用块级元素将引用文字包含,而在非strict型中就不必了,但是建议这样这样做,因为strict型文档更严格,也算是向后兼容了。

原文链接:https://m.jb51.net/web/6434.html

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 十月更新修复了Windows 10的Ping of De

    十月更新修复了Windows 10的Ping of De

  • Windows10 UAC弹窗太烦但又不能关?教

    Windows10 UAC弹窗太烦但又不能关?教

  • 老大手把手教我玩 Git 变基!

    老大手把手教我玩 Git 变基!

  • 在Linux终端中展示幻灯片

    在Linux终端中展示幻灯片

腾讯云代理商
精彩导读
海外云服务器
热门资讯
腾讯云代理商