- 浏览: 786739 次
- 性别:
- 来自: 大连
文章分类
- 全部博客 (417)
- ASP.NET MVC (18)
- WEB基础 (24)
- 数据库 (69)
- iPhone (20)
- JQuery (3)
- Android (21)
- UML (8)
- C# (32)
- 移动技术 (19)
- 条码/RFID (6)
- MAC (8)
- VSS/SVN (6)
- 开卷有益 (4)
- 应用软件 (1)
- 软件工程 (1)
- java/Eclipse/tomcat (61)
- 英语学习 (2)
- 综合 (16)
- SharePoint (7)
- linux (42)
- Solaris/Unix (38)
- weblogic (12)
- c/c++ (42)
- 云 (1)
- sqlite (1)
- FTp (2)
- 项目管理 (2)
- webservice (1)
- apache (4)
- javascript (3)
- Spring/Struts/Mybatis/Hibernate (4)
- 航空业务 (1)
- 测试 (6)
- BPM (1)
最新评论
-
dashengkeji:
1a64f39292ebf4b4bed41d9d6b21ee7 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
zi_wu_xian:
PageOffice操作excel也可以设置表格的行高列宽,并 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
wanggang0321:
亲,我在pptx(office2007以上版本)转pdf的时候 ...
JODConverter]word转pdf心得分享(转) -
xiejanee:
楼主:你好!我想请问下 你在代码中用DOMDocument* ...
Xerces-C++学习之——查询修改XML文档 (转)
Document Type Declaration
A Document Type Declaration , or DOCTYPE , is an instruction that associates a particular SGML or XML document (for example, a webpage ) with a Document Type Definition (DTD) (for example, the formal definition of a particular version of HTML ). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.
The HTML
layout engines
in modern web browsers
perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as text/html
determines a layout mode, such as "quirks mode
" or "standards mode". The text/html
serialization of HTML5
,
which is not SGML-based, uses the DOCTYPE only for mode selection.
Since web browsers are implemented with special-purpose HTML parsers,
rather than general-purpose DTD-based parsers, they don't use DTDs and
will never access them even if a URL is provided. The DOCTYPE is
retained in HTML5 as a "mostly useless, but required" header only to
trigger "standards mode" in common browsers.[
1]
Contents |
[edit ] DTDs
[edit ] Syntax
The general syntax for a document type declaration is:
<!DOCTYPE root-element PUBLIC "FPI" ["URI"] [ <!-- internal subset declarations --> ]>
or
<!DOCTYPE root-element SYSTEM "URI" [ <!-- internal subset declarations --> ]>
In XML, the root element of the document is the first element in the document. For example, in XHTML , the root element is <html>, being the first element opened (after the doctype declaration) and last closed. The keywords SYSTEM and PUBLIC suggest what kind of DTD it is (one that is on a private system or one that is open to the public). If the PUBLIC keyword is chosen then this keyword is followed by a restricted form of "public identifier " called Formal Public Identifier (FPI) enclosed in double quote marks. After that, necessarily, a "system identifier" enclosed in double quote marks, too, is provided. For example, the FPI for XHTML 1.1 is "-//W3C//DTD XHTML 1.1//EN" and, there are 3 possible system identifiers available for XHTML 1.1 depending on the needs, one of them is the URI reference "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ". If, instead, the SYSTEM keyword is chosen, only a system identifier must be given. It means that the XML parser must locate the DTD in a system specific fashion, in this case, by means of a URI reference of the DTD enclosed in double quote marks. The last part, surrounded by literal square brackets ([]), is called an internal subset which can be used to add/edit entities or add/edit PUBLIC keyword behaviours.[ 2] The internal subset is always optional (and sometimes even forbidden within simple SGML profiles, notably those for basic HTML parsers that don't implement a full SGML parser).
On the other hand, document type declarations are slightly different in SGML-based documents such as HTML, where you may associate the public identifier with the system identifier. This association might be performed, e. g., by means of a catalog file resolving the FPI to a system identifier.[ 3]
[edit ] Example
The first line of many World Wide Web pages reads as follows:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
This Document Type Declaration for XHTML includes by reference a DTD, whose public identifier
is -//W3C//DTD XHTML 1.0 Transitional//EN
and whose system identifier is http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
.
An entity resolver may use either identifier for locating the
referenced external entity. No internal subset has been indicated in
this example or the next ones. The root element is declared to be html
and, therefore, it is the first tag to be opened after the end of the
doctype declaration in this example and the next ones, too. The html tag
is not part of the doctype declaration but has been included in the
examples for orientation purposes.
[edit ] HTML 4.01 DTDs
Strict DTD does not allow presentational markup with the argument that Cascading Style Sheets should be used for that instead. This is how the Strict DTD looks:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
Transitional DTD allows some older PUBLIC and attributes that have been deprecated :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>
If frames are used, the Frameset DTD must be used instead, like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html>
[edit ] XHTML 1.0 DTDs
XHTML 's DTDs are also Strict, Transitional and Frameset.
XHTML Strict DTD. No deprecated tags are supported and the code must be written correctly.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
XHTML Transitional DTD is like the XHTML Strict DTD, but deprecated tags are allowed.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
XHTML Frameset DTD is the only XHTML DTD that supports Frameset. The DTD is below.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
[edit ] XHTML 1.1 DTD
XHTML 1.1 is the most current finalized revision of XHTML, introducing support for XHTML Modularization . XHTML 1.1 has the stringency of XHTML 1.0 Strict.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
[edit ] XHTML Basic DTDs
XHTML Basic 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
XHTML Basic 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
[edit ] XHTML Mobile Profile DTDs
XHTML Mobile Profile 1.0
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
XHTML Mobile Profile 1.1
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
XHTML Mobile Profile 1.2
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
[edit ] XHTML + RDFa DTD
XHTML+RDFa 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html lang="ar" dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
[edit ] HTML5 DTD-less DOCTYPE
HTML5
uses a DOCTYPE
declaration which is very short, due to its lack of references to a
Document Type Definition in the form of a URL and/or FPI. All it
contains is the tag name of the root element of the document, HTML
.[
4]
In the words of the specification draft itself:
In other words,
<!DOCTYPE HTML>
, case-insensitively.
With the exception of the lack of a URI or the FPI string (the FPI
string is treated case sensitively by validators), this format (a
case-insensitive match of the string !DOCTYPE HTML
) is the same as found in the syntax of the SGML based HTML 4.01 DOCTYPE
.
Both in HTML4 and in HTML5, the formal syntax is defined in upper case
letter, even if both lower case and mixes of lower case upper case are
also treated as valid.
In XHTML5
the DOCTYPE
has to be a case-sensitive
match of the string "<!DOCTYPE html>
". This is because in XHTML
syntax all HTML PUBLIC are required to be in lower case, including the root element referenced inside the HTML5 DOCTYPE
. As well, XHTML only accepts the upper case inside the DOCTYPE
string. These rules are not defined by the HTML5 specification itself
but by XML and the syntax rules for XHTML DTDs. For the XHTML5 syntax,
then Document Type Definitions are permitted as well.
The DOCTYPE
is optional in XHTML5 and may simply be omitted,[
5]
though many layout engines render such documents in Quirks mode
. This would be a problem whenever the document is supposed to be consumed by text/html
parser as well as by XHTML (application/xhtml+xml
)
parsers. Given, however, that the HTML5 specification forbids
XML-serialized HTML5 (XHTML5) from being served with any MIME type other
than application/xhtml+xml
,
this is unlikely to be a situation encountered in the real-world.
Unlike with the previous versions of XHTML, it is impossible to serve an
XHTML5 (that is, HTML5 serialized as XML) document as text/html
in any conceivable situation; any situation involving XHTML5 will be served as application/xhtml+xml
and parsed as XML in a standards-compliant system.
发表评论
-
ie firefox 读取文件
2013-02-21 11:09 0<!DOCTYPE HTML PUBLIC " ... -
js读写文件
2013-02-21 10:49 803<script> /* object.Open ... -
sessionStorage 、localStorage 和 cookie 之间的区别(转)
2013-02-20 16:00 909sessionStorage 和 localStorage ... -
html5本地存储 localStorage
2013-02-20 15:45 836<!DOCTYPE HTML> <html& ... -
html5本地存储-留言板
2013-02-20 15:44 4382<!DOCTYPE HTML> <html& ... -
myinfo
2013-02-20 09:40 0https://www.ibm.com/developerwo ... -
web.xml 中的listener、 filter、servlet 加载顺序及其详解
2013-01-21 15:05 767http://www.cnblogs.com/JesseV/a ... -
通过js闭包实现减少前后台交互的次数
2013-01-06 10:49 0应用场景:鼠标移到超链接时,会显示tip,而tip的内容来自后 ... -
js闭包的理解(转)
2013-01-06 10:38 885转自:http://www.cnblogs.com ... -
js闭包
2013-01-06 10:21 822http://www.jb51.net/article/241 ... -
js date对象
2012-12-28 14:28 1056Date 对象用于处理日期和时间。创建 Date 对象的语法: ... -
JS Date格式化为yyyy-MM-dd类字符串
2012-12-28 14:27 1183Date.prototype.format = functio ... -
js数组(转)
2012-12-11 11:38 1011js数组的操作 用 js有很久了,但都没有深究过js的数组形式 ... -
js使用
2012-11-29 10:53 9331. js split <script language ... -
.NET 的 WCF 和 WebService 有什么区别?(转载)
2012-05-07 10:28 1782<h2> <a id="cb ... -
在线文档显示组件 FlexPaper
2011-12-19 14:24 1117FlexPaper 是一个开源轻量级的在浏览器上显示各种 ... -
Doctype
2011-12-08 15:04 906DOCTYPE不可怕,但把它拿 ... -
XHTML 和 MIME 类型
2011-12-09 09:12 1122XHTML 和 MIME 类型 - 使用Web 标 ... -
xhtml DTD
2011-11-30 16:18 840XHTML 定义了三种文件类型声明。 使用最普遍的是 ... -
IIS配置
2011-11-17 13:18 820http://bbs.51cto.com/thread-488 ...
相关推荐
**DTD(Document Type Definition,文档类型定义)**是一种用于验证 XML 文档结构的技术。它通过定义一组规则来确保 XML 文档中的元素、属性等按照既定的方式进行组织。DTD 的存在确保了 XML 文档的一致性和准确性。...
- XML文档由三部分组成:XML标头信息(prolog)、DTD(Document Type Declaration)声明和文件实例集合。 - XML标头信息包含version、encoding和standalone属性,分别定义了XML文档遵循的版本、使用的字符编码和...
1. XML语法:XML文档结构严谨,包含声明(document type declaration)、元素(elements)、属性(attributes)、文本内容(text content)以及注释(comments)。例如,`<?xml version="1.0" encoding="UTF-8"?>` ...
DOCTYPE(Document Type Declaration)是 HTML 文档的开头部分,告知浏览器使用哪个版本的 HTML 规范来渲染文档。标准模式(Standards mode)以浏览器支持的最高标准运行,而混杂模式(Quirks mode)中页面是一种...
DOCTYPE是Document Type Declaration的缩写,用于告诉浏览器该文档遵循哪个HTML或XHTML的版本标准。在这个例子中,使用的是HTML5的DOCTYPE声明, δηλDOCTYPE html。 HTML文档头(Head) HTML文档头是HTML文档的...
- 文档声明(Document Type Declaration, DTD):可选,用于定义文档结构和元素的规则。 - XML声明(XML Declaration):`<?xml version="1.0" encoding="UTF-8"?>`,指定XML版本和字符编码。 - 元素(Elements)...
DOCTYPE,全称Document Type Declaration,即文档类型声明,用于告知浏览器当前文档遵循的XHTML或HTML版本。这一行看似简单的代码实则包含了丰富的信息,它不仅声明了文档的类型,还指定了该文档应遵循的DTD...
这通常包括创建文档类型声明(Document Type Declaration,DTD)以及文档的根元素。文档类型声明定义了XML文档的版本和其他元数据。 ##### 示例代码分析 **创建文档类型声明** ```php $dom = new DOMDocument(...
- 文档声明(Document Type Declaration, DTD):非必需,但可以用来定义文档的结构和元素。 - XML声明:告知解析器文档是XML格式,如`<?xml version="1.0" encoding="UTF-8"?>`。 - 元素(Element):XML文档的...
XML文档的顶部通常有一个文档声明(Document Type Declaration,DTD)或XML Schema(XSD),用于定义元素和属性的规则。这些规则确保了文档的一致性和有效性。例如,DTD可以定义元素的顺序、数量以及允许的子元素。 ...
HTML文件的基本结构分为三部分:文档声明(Document Type Declaration)、头部(Head)和主体(Body)。文档声明,如`<!DOCTYPE html>`,告诉浏览器文档遵循的HTML版本。头部包含元数据,如标题、样式表和脚本链接,...
XML文档必须遵循一定的结构,包括文档声明(Document Type Declaration)、根元素(Root Element)以及元素嵌套规则。文档声明用于指定文档类型,例如`<?xml version="1.0" encoding="UTF-8"?>`。 3. XML元素 XML的...
DOCTYPE documentType>`。文档类型声明可以指向一个文档类型定义(DTD),后者定义了文档的结构和元素间的相互关系。 #### 文档类型定义(Document Type Definition, DTD) DTD是一种用于定义XML文档结构的规范。它...
- **文档类型声明(Document Type Declaration)**:定义文档的类型和结构,例如`<!DOCTYPE ChooseFlash>`,通常需要引用DTD(Document Type Definition)文件。 - **处理指令(Processing Instructions)**:向处理器...
XML文档必须包含文档声明(Document Type Declaration,如`<?xml version="1.0"?>`),用于指定XML版本和字符编码。根元素(如上例中的`<book>`)包裹整个文档内容,确保文档结构完整。 三、XML命名规则 XML元素和...
- 文档声明(Document Type Declaration, DTD):可选,用来指定文档类型。 - XML声明:指出文档是XML格式,并提供版本和编码信息。 - 根元素:所有其他元素的父元素,确保文档有一个封闭的结构。 2. XML语法 -...
XML文档由文档声明(Document Type Declaration, DTD)或XML Schema定义其结构。DTD或XML Schema提供了验证XML文档是否符合规范的规则。文档的根元素包围所有其他元素,形成树状结构。 三、XML解析 XML解析分为两种...
1. **XML基础**:XML的基本结构和语法规则,包括元素(Element)、属性(Attribute)、文本内容(Text)、注释(Comment)、处理指令(Processing Instruction)以及XML文档声明(Document Type Declaration)等。...
DOCTYPE 是 Document Type Declaration 的缩写,用于声明文档类型,告诉浏览器文档遵循哪个版本的HTML或XHTML标准。在HTML5之前,DOCTYPE声明通常会引用一个DTD(Document Type Definition),以确保浏览器按照特定...
XML文档的开头通常有一个文档声明(Document Type Declaration,DTD)或XML Schema,用来定义文档的结构和数据类型。例如: ```xml <!DOCTYPE book [ <!ELEMENT book (title, author, year)> <!ELEMENT title (#...