[Drupal] What is DTD and how should it be implemented in a Drupal website?
DTD stands for Document Type Declaration. We have been using this as the header in all HTML files since the very first day we started working on HTML. But have you ever wondered what it does or what can happen if doctype is not specified? Read on to know what is DTD and how it should be implemented in a Drupal website
DTD tells the validator how and against what version of XHTML the page should be validated.
It checks the code to see whether the page complies with the corresponding XHTML standards and checks whether it logs the corresponding errors.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
How to declare the doctype of an HTML page?
You can declare your doc style as shown below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
You can choose the level of strictness based on which the validation has to be conducted.
In Drupal 7, the DTD is implemented in html.tpl.php which is located in modules/system/html.tpl.php
Now what is going to happen if we don't include the DTD on our website? You won't be able to validate your code correctly because the validator requires doctype declaration to continue with everything else. Moreover stylesheets in your website will not work as intended and the site can act weird in browsers like IE.