w3resource

HTML5 doctype

DOCTYPE

DOCTYPE is the first thing which should be present in an HTML5 document.

HTML5 doctype is written as <!doctype html>

'DOCTYPE' keyword is not case sensitive. So, <!doctype html> or <!DOCTYPE html>, both will do.

HTML5 doctype does not reference to a DTD. This is because, html5 is a SGML based, unlike HTML4.01 or XHTML1.

As soon a browser finds <!doctype html> in the starting of an HTML document, it represents the document in standard mode. If you don't use a doctype in the starting of an HTML document, the browser goes to the quirky mode. In that case, you may find that certain content is not being displayed the way you marked them up. So, it is a good practice to start your HTML document with a doctype.

Even if you don't use any other new HTML5 tag or feature, since the browser goes to the standard mode, you can use the doctype of html5.

Browser support

All the modern browsers like Firefox, Internet Explorer, Chrome, Safari, and Opera supports html5 doctype.

An example HTML5 document with HTML5 doctyype

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset=utf-8>
<title>HTML5 doctype example</title>
</head>
<body>
<h1>Tutorial of HTML5 doctype</h1>
<p>HTML5 has loads of new exiciting features.</p>
</body>
</html>

Previous: HTML5 Tutorial
Next: HTML5 Article Element Tutorial

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.