문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top