HTML DOCTYPE: WHY IT IS IMPORTANT
When working with HTML, you will often declare the DOCTYPE at the beginning of an HTML file.
In this article, you will learn about what HTML DOCTYPE is, and HTML DOCTYPE syntax. You will also learn about why HTML DOCTYPE declaration is important.
What is HTML DOCTYPE?
The HTML DOCTYPE is a declaration that tells the web browser which version of HTML the web page is written in. HTML DOCTYPE tells the browser how to display your webpage correctly. Here is what declaring an HTML DOCTYPE looks like:
<!DOCTYPE html>
The DOCTYPE is usually declared at the beginning of your HTML file, that is, the DOCTYPE declaration should be in the first line of your HTML file. Here is an example of declaring an HTML DOCTYPE at the beginning of an HTML file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>TESTING!!</h1>
<script src="testing.js"></script>
</body>
</html>
The HTML DOCTYPE declaration has three parts:
< >are angle brackets used in HTML.!tells the browser that this is not a normal HTML tag.DOCTYPE htmlstands for DOCUMENT TYPE. It simply tells the browser, this is an HTML file.
Why HTML DOCTYPE is Important.
Ensures proper rendering:
DOCTYPEdoes the job of telling your browser to follow modern web standards (current rules and technologies browsers follow to display websites correctly).Improves different browser compatibility:
DOCTYPEhelps make sure your website looks consistent across all browsers, because different browsers like Chrome, Firefox, Edge behave differently.Supports Modern HTML5:
DOCTYPEtells the browser you are using HTML 5, the current standard.
Summary
In this article, we talked about what HTML DOCTYPE declaration is.
We saw an example of declaring HTML DOCTYPE in our HTML.
We also saw the importance of declaring the HTML DOCTYPE in our code.

