5

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
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> and <!DOCTYPE html>
    – Smaller
    May 30, 2016 at 22:36
  • The former is a limited-quirks mode giving doctype in modern browsers, the latter is a no-quirks mode giving doctype. It's unlikely that SEO is affected at all.
    – Alohci
    May 31, 2016 at 0:22

2 Answers 2

8

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">
1
  • which one preferable to use in daily life and which one is newer ? with xhtml extension
    – M Siddique
    Mar 27, 2018 at 9:38
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.