Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does every html page with doctype need internet connection to render page properly?

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.

like image 674
Jitendra Vyas Avatar asked Dec 31 '09 19:12

Jitendra Vyas


People also ask

What will happen if the DOCTYPE is not specified in an HTML Web Page?

The absence of the DOCTYPE or its incorrect usage will force the browser to switch to quirks mode. It means that the browser will do its best to layout the page that is considered to be old or created against web standards.

Do all HTML documents require a DOCTYPE?

All HTML documents must start with a <! DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect.

What is DOCTYPE >? Why is it necessary to be declared in the HTML page?

The HTML document type declaration, also known as DOCTYPE , is the first line of code required in every HTML or XHTML document. The DOCTYPE declaration is an instruction to the web browser about what version of HTML the page is written in. This ensures that the web page is parsed the same way by different web browsers.

Is it necessary to use DOCTYPE in HTML?

All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.


2 Answers

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.

like image 138
Brian Campbell Avatar answered Oct 12 '22 15:10

Brian Campbell


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.

like image 28
Oded Avatar answered Oct 12 '22 14:10

Oded