Question

When I look at the XHTML doctype, there's a .dtd file.

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

What's the purpose of it?

Do browsers actually access it and use it to parse HTML?

If so, what happens when w3.org goes down?

Was it helpful?

Solution

The document type definition is basically there to tell the browser what version of HTML is being used. It dates back to SGML (Standard Generalised Markup Language). SGML was basically used to explain to the browser how to understand the structure of a document (such as an HTML page). Interestingly enough, XML is a restricted subset of SGML with many (exotic) features turned off.

Browsers do use it to parse the document but they don't need to nuke the W3C servers with a request every time a document is fetched. Instead they use a cached local copy.

When W3C.org goes down, they continue to use the cached copy. Unless you specify another URL of course...

One more thing to note with regard to the DOCTYPE declaration is that it is gone in HTML5, because HTML5 is no longer based on SGML. HTML5 uses <!DOCTYPE html>.

OTHER TIPS

Browsers do not actually read that file from w3.org.

Instead, they have a list of known DTD URIs, and they know how to handle each one. (probably using a copy of the DTD file embedded in the browser)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top