Open In App

Explain the purpose of DOCTYPE in HTML

The DOCTYPE in HTML acts like a blueprint, telling web browsers how to understand and display a webpage. Here’s why it matters:

In short, DOCTYPE is like a web language tag that ensures your page speaks the same language as browsers, avoiding confusion and ensuring a smooth viewing experience.



Syntax

<!DOCTYPE html>

Example: Example illustrates the use of Doctype.




<!DOCTYPE html>
<html>
  
<head>
    <title>Doctype Example</title>
</head>
  
<body>
    <h2>Welcome To GFG</h2>
    <p>Default code has been loaded into the Editor.</p>
</body>
  
</html>

Output:



Article Tags :