DOCTYPE - Document type declaration



Q1. What is document type declaration or DOCTYPE ?
Ans. The <!DOCTYPE> declaration must be the first thing in your HTML document, before the <html> tag; it is an instruction to the web browser about what version of HTML the page is written in and also associates a particular SGML or XML document with a document type declaration (DTD). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.



Q2. What DOCTYPE declaration contains ?
Ans. A DOCTYPE declaration can contains -

  • The name of the document or root element
  • System and public identifiers for the DTD that can be used to validate the document structure.
  • An internal subset of DTD declaration.
Q3. Why specify a DOCTYPE ?
Ans. A DOCTYPE is specified because it defines which version of (XHTML) your documents is actually using, and this is a critical peice of information needed by some tools processing the documents.

Note - A DOCTYPE declaration is mandatory if the document is to be processed in a validating environment. To be valid, the DOCTYPE declaration must identify a DTD that corresponds to the document structure of the document. Non-validating parser will accept documents without DOCTYPE declarations.


Q4. Syntax ?
Ans. The general syntax for a document type declaration is;

<!DOCTYPE root-element PUBLIC "FPI" ["URI"] [
<!---internal subset declaration-->
]>


  • The root element is the first element opened and last closed "in XHTML the root element is <html>"
  • The keyword SYSTEM and PUBLIC suggest what kind of Document type Definition (DTD) it is "there are two type of DTD are one is private system and other is open to public". If the PUBLIC keyword is chosen then this keyword is followed by a restricted form of "public identifier" called Formal Public Identifier (FPI) enclosed in double quote marks.

Reference -
wikipedia
www.w3schools.com
http://msdn.microsoft.com

Comments

Popular posts from this blog

Artificial Intelligence

Biometrics

Smart Card