- Courses
- HTML
- HTML top level tags
- <!DOCTYPE>
- Purpose of the doctype in HTML
What is the purpose of the <doctype html>
in HTML documents?
The <doctype html> ensures the browser renders the page in standards mode.
It prevents the browser from switching to quirks mode, which can cause inconsistent rendering across different browsers. By using the doctype, developers ensure that the browser follows the HTML specifications as closely as possible.
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>