Skip to main content

Definition of Document Type

The Definition of Document Type, or DTD, specifies the HTML version that is being used in the source code of a website. Therefore, a browser or other reading software can display the content of the source code since it is able to detect what type of document it is. In the past, many browsers did not display content when a missing or incorrect DTD was listed. However, the current HTML5 standard no longer requires the DTD specification to display the web correctly, but rather, to validate it against the document type definition. The standard for the definition of the document class has been set by the W3C.

Origin

HTML has been used as a markup language for many years. In this way, HTML is enabled in many versions. The latest version is HTML5. Older versions, such as XHTML or HTML4, are used today on older sites. HTML was originally based on the SGML meta markup language. The DTD described the structure of the documents, which were created with subsets (XML) or apps (HTML) by SGML. With the development of HTML5, these compounds have been removed. HTML5 is no longer an SGML application, but a generalized language compatible with previous versions.

The document type definition for HTML specifies what version is being used in the source code of a web document. This information must be provided so that the app (the browser) can detect what type of document it is and what markup is allowed. However, modern browsers display the content of an HTML document when the DTD is missing, but an HTML file is only valid if entered with a clearly defined document type. This, in turn, is established with the definition of the document type . Specifies what characters can be used in an HTML document and what attributes should be used. Each HTML document must include a header and a body element and also be listed in a certain logical structure (tree structure), to be valid.

<!DOCTYPE html>
<html lang="de">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
  </body>
</html>

Document type definitions for browsers

When a website is accessed through a browser, it will download the document type definition specified in the source code and apply it to the document upon opening, in order to correctly interpret the characters contained therein. Browsers such as Mozilla Firefox, Internet Explorer from Windows or Google Chrome are W3C compliant and can interpret different document type definitions. However, there is the opportunity for errors to be generated on the screen and when reading from CSS for websites that use older versions of the document type definition. Other browsers like Opera only interpret HTML pages based on the most current standards. Therefore, the risk of errors is reduced. The DTD thus serves to mark valid HTML documents and the probability of a correct representation increases when they are valid.

Building

The W3C has proposals for common definitions of HTML document type, but each webmaster must eventually make some adjustments to their website to ensure that it displays correctly in all browsers. The document class specification is the first entry in the source code of an HTML page. The DTD specification is case-sensitive. The document class string it must be in uppercase.


In XHTML, the XHTML version specification is the first in the list:


An example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de">

The address after the document type specifies the path to the document class definition. The browser can download the definition there and apply it to the current document. If you specify "public", the source for the document type definition is public. The language specification, ie EN, does not refer in this circumstance to the language used in the content, but to the language version of the HTML definition. Thus, a document class term for HTML must always refer to EN.

Definitions of common document types for HTML / XHTML websites

There are some differences in how to indicate the DTD in different versions of HTML.

DTD for HTML 4

There are three different definitions for HTML 4:

  • Strict HTML 4.01: In an HTML document of this type, only structuring items are allowed in the source code. The format and layout are controlled by style sheets. Thus, the HTML source code is very easy and fast to read.

Example line for this type of document:


  • Transition to HTML 4.01: This type of document specifies that both HTML attributes and style sheets are used in it. It is a transitory term.

The sample line for this class is as follows:


  • HTML 4.01 framework set: With this document class, it is specified that the HTML file contains a collection of frames, that is, individual windows. The HTML items and the BODY (body) are declared here differently. All items in the body are replaced by the FRAMESET.

This definition applies to pages with sets of framesets:


DTD for XHTML

XHTML 1.0 is based on the same rules as HTML 4.01. The only difference is that this markup language is based on XML and not SGML. For XHTML, three different types can be specified. The same features that apply to HTML document types also apply to XHTML documents. The following are relevant examples of the information that should be listed:

  • Strict XHTML 1.0:

  • XHTML 1.0 transitional:

  • Frameset XHTML 1.0:

  • XHTML 1.1 is no longer bound to HTML 4.01 rules. In this way, only one document class term remains:

DTD for HTML5

The definition of the document class has been simplified with HTML5:


Document type definition for websites and SEO

Since document type definition for HTML pages was an important factor for the correct display of web content, ensuring the accuracy of these definitions is still part of optimizing a page. Only if all the content of a website can be shown as desired to practically all users, analyzes can be carried out with the appropriate results and it can be achieve marketing goals. Many users still use older browsers that require DTD specifications. If errors occur, it does not necessarily affect the appearance of the web, since most browsers can still display the content. But HTML documents can contain a lot of errors and the browser will parse them anyway. This takes time and users will have to wait longer.

Choosing the appropriate document type definition further determines how thin the source code of a web portal will be and what the text / code link is. Because the loading speed is a positioning criterion In search engines, selecting the correct definition of the document type can be advantageous when loading the page. The browser can detect the type of document quickly, to render the content. At the same time, the link between the source code and the text is also considered relevant from an SEO perspective. There should be more text and less source code.

Web Links