Last Updated : 17 Jul, 2025
HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.
<!DOCTYPE html>
at the top of your HTML file for HTML5.< !DOCTYPE html >
Note: The <!DOCTYPE> declaration is NOT case-sensitive.
How HTML Doctype tell the browser which version of html it is?The <!DOCTYPE>
declaration doesn’t directly specify which version of HTML is being used (like, "HTML5" or "HTML4"), but rather it tells the browser to use a specific rendering mode. It helps the browser determine how it should interpret the content. There are two main modes:
Here, for example, we declare <!DOCTYPE html>, which triggers standard mode and tells the browser to use HTML5 specifications.
index.html
<!DOCTYPE html>
<html>
<body>
<p>welcome to my website</p>
</body>
</html>
What Happens Without <!DOCTYPE html>
Without <!DOCTYPE html>
, your HTML code can still run, but it may face several significant drawbacks:
<!DOCTYPE>
, rendering becomes unpredictable, making debugging more challenging and leading to unpredictable page behavior when adding new features.<!DOCTYPE html>
HTML 4.01 Strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Transitional <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Frameset <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Transitional <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 Frameset <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Best Practices When Using DOCTYPE
The <!DOCTYPE>
declaration is a critical part of every HTML document. It ensures that browsers render your page using standards mode, avoiding unpredictable behaviors and maintaining consistency across all modern browsers. With 100% browser support, the HTML5 <!DOCTYPE html>
is simple, effective, and essential for building reliable web pages.
By understanding its purpose, knowing how to apply it correctly, and recognizing its role in HTML structure and browser behavior, developers can prevent common rendering issues and create more consistent, professional websites.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4