Doctype in HTML

HTML doctype is the instruction about what version of HTML the page is written in, passed to the web browser. It is used to make sure that it is parsed in a similar way by different web browsers.

doctype is a document type declaration (DTD), which informs the browser about the document to be expected on the webpage.

Doctype Usage

The HTML doctype serves as an instruction to the browser about the markup.

In the 4.01 version of HTML, the refers to Document Type Declaration (DTD). This happens because the 4.01 version of HTML is based on Standard Generalized Markup Language(SGML). Thus the reference is done so that the browser displays the content properly.

Document Type Declaration is a set of instructions that links with a specific XML or SGML document. In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

The newer versions of HTML are not based on Standard Generalized Markup Language(SGML). Thus, it doesn’t need to refer to Document Type Declaration. Thus, the doctype in the newer version is only used to enable the standard form of writing the documents.

Syntax:

<!DOCTYPE html>

Example

Following is a basic HTML 5 document, with HTML 5 doctype. This is a standard way of writing HTML.

<!-- The DOCTYPE is mentiond on the TOP of the document and it tells the browser that the document is a HTML document -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Html links</title>
</head>
<body>
    <p>This is a basic HTML document.</p>
</body>
</html>

Related Posts

What are custom events in JavaScript?

Custom events are the events that allow you to decouple the code you want to run after a specific piece of code runs. There are various in-built events…

How to use nested for loop in JavaScript?

We use the for loop statement of JavaScript for repeating a set of statements inside the loop body a specified number of times. A nested for loop, as the…

What are the basic rules for JavaScript parameters?

A JavaScript function is a code that performs a particular task. The function parameters are the name list in the function definition. Parameters are also known as…

How to stop refreshing the page on submit in JavaScript?

Using event.preventDefault() to stop page refresh on form submit In this section, we will see how to use event.preventDefault() to stop page refresh on form submission. The event.preventDefault() restricts the default…

Target a Window Using JavaScript or HTML

TARGET attribute of HTML A link’s opening named frame or window is specified using the Target attribute of the <a> anchor tag. The concluding </a> tag in…

What is the role of deferred scripts in JavaScript?

Since JavaScript is a loosely typed language, you are not required to correctly predict the kind of data that will be kept in a variable. Depending on the information…