Problem Statement
Explain the purpose of DOCTYPE in HTML.
Explanation
The DOCTYPE declaration has two main purposes. First, it tells the browser which HTML version the page uses, so it can render correctly.
Second, it makes the browser use standards mode instead of quirks mode. Standards mode follows modern web standards strictly. Quirks mode is for older websites with non-standard code. \n For HTML 5, the DOCTYPE is simply DOCTYPE html, which is much simpler than older versions. The DOCTYPE must be the very first line, even before the html tag. Without it, browsers may use quirks mode, causing display issues across different browsers. Remember, DOCTYPE is not an HTML tag. It is an instruction to the browser.
Code Solution
SolutionRead Only
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOCTYPE Example</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>