完美WEB

css,xhtml,javascript,DOM,亲和力,web内容可用性教程,希望web变得更完美。

IE盒模型bug和修复 »

DOCTYPE(文档类型)

DOCTYPE是document type(文档类型)的简写,用来说明你用的XHTML或者HTML是什么版本。

他们是什么和他们为什么是重要的?

  1. 所有的HTML和XHTML文档必须有一个有效的doctype声明。
  2. Doctype规定了文档使用的HTML或XHTML的版本。
  3. 当校验的时候doctype被校验器使用,WEB浏览器通过它来决定那种渲染模式被使用。
  4. Doctype影响设备渲染web页面的方式。
  5. 如果文档使用了正确的doctype,一些浏览器将切换到标准模式,那意味着浏览器会遵守更多的CSS规则。
  6. 如果文档使用了正确的doctype,文档会渲染更快,因为浏览器不需要花时间去思考怎样正确地去渲染HTML。

主要的几种DOCTYPE

HTML 4.01 Strict

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

在上面的声明中,声明了文档的根元素是html,它在公共标识符为"-//W3C//DTD HTML 4.01//EN"的DTD中进行了定义。浏览器将明白如何寻找匹配此公共标识符的DTD。如果找不到,浏览器将使用公共标识符后面的URL作为寻找DTD的位置。

HTML 4.01 Transitional

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Standards compliant (or strict) and quirks modes

大多数浏览器有两种模式:怪异模式(quirks mode 使用老的规则)和严格模式(strict mode遵守标准)。Mozilla, Safari, Opera, Mac/Explorer, Windows/Explorer 6实现了这两种模式。Windows/Explorer 5和老的浏览器像Netscape 4执行的是怪异模式。

使用严格模式(strict mode 或者说遵守标准的模式)有一些非常重要的原因。例如,Windows/Explorer 6 将会使用正确的盒模型(box model)当使用strict mode 时,而使用quirks mode 时会执行错误的盒模型。另外在quirks mode下,一些现代的浏览器将不允许fonts被继承。

XML声明需要吗?

W3C推荐在XHTML文档里使用XML声明,但也不是必须要这么做。所以这就要看开发者本人来决定了。如果有了这个声明,Windows/IE6将会忽略任何使用的doctype 而执行quirks mode。XML声明看起来如下示:
<?xml version="1.0" encoding="utf-8"?>

关于DOCTYPE你也可以看看阿捷的选择什么样的DOCTYPE这篇文章。

如果想对DOCTYPE了解更多细节,可以阅读《网站重构》122页或者《HTML和XHTML权威指南(第五版)》580页。

此文禁止转载,但是您可以以超级链接的方式链接到这篇文章。

  • ambean(引用)
  • ambean
  • you think my sites too brilliant?
  • 2007-5-16 15:03:34
  • prillosec(引用)
  • prillosec
  • admins whos create this site, thanks guys.
  • 2007-5-16 15:31:42
  • coddeine(引用)
  • coddeine
  • you think my sites too brilliant?
  • 2007-5-16 15:56:49
  • fiorciet(引用)
  • fiorciet
  • Now I dont have to feel so intimated by science!
  • 2007-5-16 15:56:57
  • merridia(引用)
  • merridia
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-17 16:23:52
  • adderal(引用)
  • adderal
  • you think my sites too brilliant?
  • 2007-5-17 16:26:29
  • atipex(引用)
  • atipex
  • admins whos create this site, thanks guys.
  • 2007-5-17 16:27:07
  • viegra(引用)
  • viegra
  • Now I dont have to feel so intimated by science!
  • 2007-5-19 7:54:40
  • lortab 10(引用)
  • lortab 10
  • Now I dont have to feel so intimated by science!
  • 2007-5-21 8:24:45
  • tremadol(引用)
  • tremadol
  • admins whos create this site, thanks guys.
  • 2007-5-21 8:25:06
  • atipex(引用)
  • atipex
  • Very interesting site!
  • 2007-5-23 1:12:54
  • vicodan(引用)
  • vicodan
  • admins whos create this site, thanks guys.
  • 2007-5-23 1:13:23
  • tremadol(引用)
  • tremadol
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-23 1:19:17
  • selebrex(引用)
  • selebrex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-23 1:22:04
  • fearicet(引用)
  • fearicet
  • Now I dont have to feel so intimated by science!
  • 2007-5-23 1:22:16
  • ultracett(引用)
  • ultracett
  • admins whos create this site, thanks guys.
  • 2007-5-23 1:23:03
  • altram(引用)
  • altram
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-23 1:23:18
  • ionami(引用)
  • ionami
  • you think my sites too brilliant?
  • 2007-5-27 3:56:12
  • zonaflex(引用)
  • zonaflex
  • admins whos create this site, thanks guys.
  • 2007-5-27 4:10:20
  • zannaflex(引用)
  • zannaflex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 2:39:06
  • zanex(引用)
  • zanex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 3:00:29
  • zolloft(引用)
  • zolloft
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 5:18:21
  • xinical(引用)
  • xinical
  • you think my sites too brilliant?
  • 2007-5-28 6:01:30
  • levetra(引用)
  • levetra
  • you think my sites too brilliant?
  • 2007-5-28 6:32:31
  • lipitore(引用)
  • lipitore
  • Now I dont have to feel so intimated by science!
  • 2007-5-30 9:51:25
  • zirtec(引用)
  • zirtec
  • admins whos create this site, thanks guys.
  • 2007-6-1 22:51:24
  • voltrax(引用)
  • voltrax
  • Now I dont have to feel so intimated by science!
  • 2007-6-1 22:51:24
  • ambean(引用)
  • ambean
  • you think my sites too brilliant?
  • 2007-6-1 22:51:35
  • zanex(引用)
  • zanex
  • you think my sites too brilliant?
  • 2007-6-2 13:14:52
  • lipitore(引用)
  • lipitore
  • Now I dont have to feel so intimated by science!
  • 2007-6-5 17:41:45
  • zirtec(引用)
  • zirtec
  • admins whos create this site, thanks guys.
  • 2007-6-5 17:42:25
  • zenical(引用)
  • zenical
  • you think my sites too brilliant?
  • 2007-6-8 5:42:10
  • cialise(引用)
  • cialise
  • you think my sites too brilliant?
  • 2007-6-8 5:53:24
  • ionami(引用)
  • ionami
  • admins whos create this site, thanks guys.
  • 2007-6-15 8:32:28
  • lortab 10(引用)
  • lortab 10
  • Now I dont have to feel so intimated by science!
  • 2007-6-15 8:40:21
  • adepix(引用)
  • adepix
  • Hello man, your site best, ciao!
  • 2007-6-15 8:42:47
  • paxel(引用)
  • paxel
  • Now I dont have to feel so intimated by science!
  • 2007-6-15 9:00:23
  • ultracett(引用)
  • ultracett
  • Now I dont have to feel so intimated by science!
  • 2007-6-15 9:03:16
  • vicaden(引用)
  • vicaden
  • you think my sites too brilliant?
  • 2007-6-15 21:45:31
  • zihromax(引用)
  • zihromax
  • Now I dont have to feel so intimated by science!
  • 2007-6-16 5:15:39
  • phetermin(引用)
  • phetermin
  • Now I dont have to feel so intimated by science!
  • 2007-6-19 2:42:51
  • flexiril(引用)
  • flexiril
  • admins whos create this site, thanks guys.
  • 2007-6-19 3:14:34
  • zolof(引用)
  • zolof
  • you think my sites too brilliant?
  • 2007-6-21 21:35:46
  • valum(引用)
  • valum
  • you think my sites too brilliant?
  • 2007-6-21 21:43:11
  • lipitorr(引用)
  • lipitorr
  • Now I dont have to feel so intimated by science!
  • 2007-6-21 21:45:34
  • adivan(引用)
  • adivan
  • you think my sites too brilliant?
  • 2007-6-21 21:55:45
  • lavitra(引用)
  • lavitra
  • you think my sites too brilliant?
  • 2007-6-21 23:02:47
  • xenicol(引用)
  • xenicol
  • admins whos create this site, thanks guys.
  • 2007-6-22 0:59:42
  • cialisis(引用)
  • cialisis
  • admins whos create this site, thanks guys.
  • 2007-6-22 1:06:58
  • adivan(引用)
  • adivan
  • you think my sites too brilliant?
  • 2007-6-22 12:17:43
  • vallum(引用)
  • vallum
  • you think my sites too brilliant?
  • 2007-6-22 12:17:49
  • zanax(引用)
  • zanax
  • you think my sites too brilliant?
  • 2007-6-22 12:17:59
  • xanex(引用)
  • xanex
  • you think my sites too brilliant?
  • 2007-6-23 12:40:11
  • acylovir(引用)
  • acylovir
  • admins whos create this site, thanks guys.
  • 2007-6-23 12:40:58
  • ambein(引用)
  • ambein
  • Hello man, your site best, ciao!
  • 2007-6-23 12:41:06
  • excema(引用)
  • excema
  • admins whos create this site, thanks guys.
  • 2007-6-23 12:57:56
  • viegra(引用)
  • viegra
  • Hello man, your site best, ciao!
  • 2007-6-25 8:15:04
  • Flux(引用)
  • Flux
  • news
  • 2007-6-28 18:02:45

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。



日历

网站目录

最新评论

最近发表

Powered By Z-Blog 1.6 Beta Build 60420

Copyright flashshe.com All Rights Reserved.