每个带有 doctype 的 html 页面都需要互联网连接才能正确呈现页面吗?

发布于 2024-08-16 03:56:24 字数 1488 浏览 5 评论 0原文

url 链接

许多文档类型使用这样的

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

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

,并且此 dtd 文件位于实时 url http://www .w3.org/TR/html4/strict.dtd

这个在线实时 dtd 有什么用,以及任何页面(使用这个文档类型)如何根据这个文档类型正确呈现,而无需访问这个 url(我意思是如果互联网访问不可用?)

更新:我从维基百科找到此信息http ://en.wikipedia.org/wiki/System_identifier

在 HTML 和 XML 中,系统标识符 是无片段的 URI 引用。它 通常出现在文档类型中 宣言。在这种背景下,它是 旨在识别文档类型 专门用于一个 应用程序,而公共 标识符的目的是识别一个 文档类型可能跨度超过 一个应用程序。

在下面的例子中,系统 标识符是包含的文本 引号内:

更新2:仅用于验证器吗? Dreamweaver等软件如何提供离线验证?

更新3:我从w3c网站http://www.w3c.com找到了此信息。 w3.org/QA/Tips/Doctype

为什么要指定文档类型?因为它 定义您的 (X)HTML 版本 文档实际上使用(版本 适用于什么浏览器或验证器?),以及 这是一个关键部分 某些工具所需的信息 (哪些工具?除了验证器之外还有其他工具吗?)处理文档。

例如,指定以下文档类型 您的文档允许您使用工具 例如标记验证器来检查 (X)HTML 的语法。此类工具 如果不这样做就无法工作 知道你是什么类型的文件 使用。

但最重要的是 对于大多数浏览器系列来说, doctype 声明会产生很多 猜测是不必要的,因此将 触发“标准”渲染模式。

many doctype use a url link

like this

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

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

and this dtd file is on live url http://www.w3.org/TR/html4/strict.dtd

What is the use of this online live dtd and how any page (which use this doctype) will render properly according to this doctype without having access to this url (i mean if internet access is not available?)

update : I found this info from wikipedia http://en.wikipedia.org/wiki/System_identifier

In HTML and XML, a system identifier
is a fragmentless URI reference. It
typically occurs in a Document Type
Declaration. In this context, it is
intended to identify a document type
which is used exclusively in one
application, whereas a public
identifier is meant to identify a
document type that may span more than
one application.

In the following example, the system
identifier is the text contained
within quotes:

update 2 : is it only to use for Validators? how some software like dreamweaver provides offline validation?

update 3: i found this info from w3c site http://www.w3.org/QA/Tips/Doctype

Why specify a doctype? Because it
defines which version of (X)HTML your
document is actually using (version
for what browser or validator?)
, and
this is a critical piece of
information needed by some tools
(which tools? any other tools then validator?) processing the document.

For example, specifying the doctype of
your document allows you to use tools
such as the Markup Validator to check
the syntax of your (X)HTML. Such tools
won't be able to work if they do not
know what kind of document you are
using.

But the most important thing is that
with most families of browsers, a
doctype declaration will make a lot of
guessing unnecessary, and will thus
trigger a "standard" rendering mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

悸初 2024-08-23 03:56:24

不,没有浏览器实际获取或验证文档类型。请参阅 DTD 在 Web 上不起作用,了解为什么获取和验证 DTD 是错误的一个很好的论据。一个坏主意。

理论上,文档类型是用来告诉文档使用哪个版本的标准。除了在怪异模式和标准模式之间切换之外,浏览器通常不使用此信息。为此,所有现代浏览器都接受最简单的文档类型,没有 URL 或版本信息,;因此,HTML5 已采用此作为推荐的文档类型。

验证器有时使用此信息来告知要验证的 DTD,但嵌入在文档中的 DTD 实际上并不是指定验证信息的好方法。针对文档中引用的 DTD 进行验证的问题在于,该文档的使用者并不真正关心该文档是否自洽,而是关心它是否遵循使用者知道如何可靠解释的模式。相反,通常最好使用更强大的模式语言(例如 RELAX NG)针对外部模式进行验证。

当验证者使用此信息时,他们经常仅使用 URI 作为标识符,而不是定位符。这意味着验证器已经了解所有常见的 HTML 文档类型,并使用该知识进行验证,而不是从引用的 URI 下载。这在一定程度上是为了避免每次都必须下载 DTD 的问题,而且还因为 DTD 实际上没有指定足够的信息来提供非常好的验证和错误消息,因此验证器的某些部分可以在自定义代码中指定或更强大的模式语言。有关详细信息,请参阅 Henri Sivonen 的论文,了解他对 validator.nu HTML5 一致性检查器。

一些验证器还可能下载并缓存 DTD,因此它们需要在线一次才能下载它,但稍后将从缓存版本开始工作。

No, no browsers actually fetch or validate against the doctype. See DTDs Don't Work on the Web for a good argument for why fetching and validating DTDs is a bad idea.

The doctype is there, in theory, to tell what version of the standard the document uses. The browsers generally don't use this information, other than to switch between quirks and standards mode. All modern browsers accept the simplest possible doctype, with no URL or version information, <!DOCTYPE html>, for this purpose; because of this, HTML5 has adopted this as the recommended doctype.

Validators sometimes use this information to tell what DTD to validate against, but DTDs embedded in the document aren't actually a very good way of specifying validation information. The problem with validating against a DTD referenced within a document is that the consumer of that document doesn't really care all that much whether the document is self-consistent, but whether it follows a schema that the consumer knows how to interpret reliably. Instead, it's generally better to validate against an external schema, in a more powerful schema language like RELAX NG.

When validators use this information, they frequently use the URI as an identifier only, not as a locator. That means that the validator already knows about all of the common HTML doctypes, and uses that knowledge for validation, instead of downloading from the URI referred to. This is in part to avoid the problem of having to download the DTD every time, and also because a DTD doesn't actually specify enough information to provide very good validation and error messages, so some parts of the validator may be specified in custom code or a more powerful schema language. For more information, see Henri Sivonen's thesis on his implementation of the validator.nu HTML5 conformance checker.

Some validators may also download and then cache DTDs, so they would need to be online once to download it, but will later work from the cached version.

许你一世情深 2024-08-23 03:56:24

URI 用于唯一标识文档类型 - 它不用于检索,并且任何浏览器(或其他软件)都不应依赖于该网址上存在的文档。

The URI is there to identify the document type uniquely - it is not meant for retrieval and no browser (or other piece of software) should rely on a document existing at that web address.

感情旳空白 2024-08-23 03:56:24

我自己也曾经想过这个问题。但如果您有自己的 HTTP 服务器,那么很容易证明这并不重要。只需将电缆拉到外部世界,看看是否仍然可以打开服务器上的页面。

I used to wonder about that myself. But if you have your own HTTP server, it's pretty easy to prove that it doesn't matter. Just yank the cable to the outside world and see if you can still open the pages on your server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文