Doctype is a piece of code that goes in the first line of an HTML webpage. Don’t worry about what’s in it just recognize that this line is a Doctype. And I said ‘a’ Doctype as the fun part is there are a whole bunch of them. Which is why it is so important for you to understand which type pertains to your website.
About Doctypes : Doctype is an abbreviation for ‘Document Type Object’ which basically summarizes that your webpage, while in document type, is actually and object and thus treated so. As you can see without this piece of code your browser may not know if your website is and object, what form it takes, and thus may be very confused as to how to render it.
Luckily IE and Mozilla will try very hard to render your page correctly but why tale a chance that thy get it right all the time? Definition- ‘Render’: When programmers talk about browsers rendering they mean exactly how the browser complies the code, what standards it follows, and how the code is projected on the screen (eg. is it what the programmer intended?).
Using a Doctype will ensure that all major browsers (IE, Mozilla, Safari, Opera) will render your website exactly the same every time it is viewed. Also for example Internet Explorer (R) 6.0 will render your site the same as 7.0. So now that you realize the importance of Doctypes, where do you head from here? Additional Information (before you begin): Doctypes are created and stored on the World Wide Web consortiums servers (W3C.org). They are in fact links to actual documents which set the standards for how browsers use code you implement in your website.
For example a Doctype will let the browser know how to calculate where an image goes on the screen when a programmer specifies its location in a percentage. Without this information the browser will revert back to its standard formatting. For example if you specify an images location as 20% to the right and your div element 22% to the right, it may look fine in mozilla and overlap in IE (and vice versa).
Thus you can see in order for your website to be rendered the same in every browser you must include a relevant Doctype. Determining the correct Doctype : Determining which Doctype you should use for your website is not very difficult as long as one MAJOR rule is followed. Don’t use the short version:
The DOCTYPE declaration, mandatoryin any document, specifies the type ofdocument that willbe created and theDTD to which itwillcomply. The first partof the statement:
<! DOCTYPE html PUBLIC “– / / W3C / / DTD XHTML 1.1 / / EN” indicatesthe generic nameof the DTD. Html part gives the name ofthe root element document. The second part:
state the address xhtml11.dtd file that contains the DTD itself. To use variants of XHTML 1.0, we have a choice between the DOCTYPE declarations following:
<! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Strict / / EN" http://www<span< a=""> style="color:#008c00; ">.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
which corresponds to the version XHTML 1.0 strict, XHTML 1.1 and before it is practicallyidentical. This is the most rigorous versions of XHTML 1.0.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
It allows the use of obsolete elements present in older versions ofHTML, such as <font> or <center> absolutely not recommended for years.This DTD has been created by the W3C as to ensure compatibility with documentsHTML developed with HTML 4 Transitional, itself created to ensure compatibilitywith HTML 3.2. Use this DTD now would be an aberration and hypocrisyto create the impression that it is XHTML. It is the very negation of the spirit ofXHTML, no offense to some, and I will not quote it from memory as discouragingformally its use.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd ">