DOCTYPEs in HTML Web Page

What is DOCTYPE and why should we use it? What different types of DOCTYPEs can I use?

Last updated:7/20/2021 12:48:23 AM

1 Answers

Ethan Karla
Ethan Karla

Doctype or Document Type Declaration is a directive that tells the web browser about the markup language in which the current web page is written. Doctype is not an element or tag, it helps the browser to know about the version or standard of HTML or any other markup language being used in the document.

A DOCTYPE declaration: A DOCTYPE declaration appears at the top of a web page before all other elements. According to the HTML specification or standards, every HTML document requires a document type declaration to ensure that pages are displayed the way they are intended to be displayed.

The DOCTYPE for HTML5 is case-insensitive and can be written as shown below:

<!DOCTYPE html>

<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title>Document Type</title>
</head>
<body>
</body>
</html>

Answer