What does DOCTYPE mean and why is it important

DOCTYPE, short for Document Type Declaration, is an instruction that tells the web browser about the version and type of HTML being used in the document. It is important because it helps ensure that the web page is rendered correctly in different browsers and establishes the standards mode for the document. Without a proper DOCTYPE, browsers may enter quirks mode, leading to inconsistent rendering.

Example of DOCTYPE Declaration

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My Web Page</title>
</head>
<body>
  <p>Welcome to my webpage!</p>
</body>
</html>

DOCTYPE HTML standards mode web browsers rendering quirks mode