Friday, August 24, 2012

HTML Doctype

How does the browser know what version of HTML we are using in our code?.A browser can display the webpage accurately only if it knows the exact HTML version used in the webpage.This is what doctype tag is used for.it is not exactly a html tag.it is just the informing the browser what version of HTML we are using.Currently we are using HTML 4.01 or XHTML 1.0 for our tutorial.so the doctype declaration for these version(s) looks like this:

For HTML 4.01:

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

For XHTML 1.0:

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

The only difference between HTML 4.01 and XHTML 1.0 is that XHTML is used with XML application(xml is just the organised representation of data in the form of tags).

  • ! is the indicator that indicates that this is an SGML declaration(SGML (Standard Generalized Markup Language) is a standard for how to specify a document markup language or tag set).
  • DOCTYPE shows that this is an SGML declaration for document type.
    • DOCTYPE is case sensitive
  • HTML names the first element that will appear in this document.
  • PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" Lists the Formal Public Identifier (FPI) for the DTD* that this document conforms to. Your SGML parser will use this to find the correct DTD when processing this document.
    • FPI Syntax "Owner//Keyword Description//Language"
  • http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd refers to source of the DTD(Document type declaration).
    • this file help the browser to decide whether to support deprecated tags from previous versions.

Stay Tuned.

0 comments:

Post a Comment