The <!DOCTYPE> declaration is an instruction that tells the web browser what version of HTML the document is using.
🔹 Why Do We Use <!DOCTYPE>?
- It ensures the browser renders the page in "standards mode" (not in quirks mode).
- Helps maintain consistent rendering across different browsers.
- Prevents unexpected behavior caused by browser-specific fallbacks.
✅ Example (HTML5):
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
<!DOCTYPE html>tells the browser to render the page using HTML5 standards.
📝 In Summary:
<!DOCTYPE> is a declaration at the top of an HTML document that ensures correct, consistent rendering by telling the browser which version of HTML to follow—essential for modern web development.