Whats the difference between these two DOCTYPE
declarations?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and
<!DOCTYPE html>
What are the consequences of using each of these, and how do they affect SEO?
2
Answers
In HTML 4.01, the
<!DOCTYPE>
declaration refers to a Document Type Definition (DTD). This is because HTML 4.01 was based on Standard General Markup Language (SGML).The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
This is why HTML5 has only one doctype. That is the second one in your example.
HTML4.0.1 on the other hand had three doctypes
Strict: This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.
Transitional: This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.
Frameset: This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.
XHTML also had three doctypes.
XHTML 1.0 Strict: This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.
XHTML 1.0 Transitional: This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.
This is the one in your first example
XHTML 1.0 Frameset: This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content.
How much a DOCTYPE will affect you is certainly dependent on the techniques used for the layout of any given page. So, if you design for IE4 using <table>s as your primary framework, you will not run into many problems. But if you use CSS for layout control and require solid control over the placement of the various elements in your pages, you will run into cross-browser compatibility issues. The most notable of these is the non-standard box model measurement in older versions of Internet Explorer that I mentioned before.