How is DOCTYPE and DTD used in a HTML page?

 
<!DOCTYPE html>
 
The <!DOCTYPE> declaration is not an HTML tag
 
The DTD specifies the rules for the markup language, so that the browsers render the content correctly. 
 Tip: Always add the <!DOCTYPE> declaration to your HTML documents, so that the browser knows what type of document to expect.

HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.

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

HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
FAQ : What is DTD?
 
A DTD defines the structure and the legal elements and attributes of an XML document.
With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
An application can use a DTD to verify that XML data is valid.

<!DOCTYPE note SYSTEM "note.dtd">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>


Seen from a DTD point of view, all XML documents are made up by the following building blocks:
  • Elements
  • Attributes
  • Entities
  • PCDATA
  • CDATA
  

Elements

Elements are the main building blocks of both XML and HTML documents.
Examples of HTML elements are "body" and "table".
Examples of XML elements could be "note" and "message".

<body>some text</body>
<message>some text</message>

Entities

Some characters have a special meaning in XML, like the less than sign (<) that defines the start of an XML tag.

PCDATA

PCDATA means parsed character data.
Think of character data as the text found between the start tag and the end tag of an XML element.

 

CDATA

CDATA means character data.
CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.

 

Analytics