skip to Main Content

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


  1. 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.

    <!DOCTYPE html>
    

    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.

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

    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">
    

    Frameset: This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.

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

    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.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    

    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

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

    XHTML 1.0 Frameset: This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search