- 3 years ago
- Shahzad Gujjar
- 1,977 Views
-
3
The document type declaration in HTML is explained in this tutorial.
Understanding the HTML5 Doctype
A Document Type Declaration, or DOCTYPE for short, informs the web browser of the markup language version used to create a web page.
A DOCTYPE declaration appears above all other elements at the top of a web page. Any HTML document, according to the HTML specification or standards, needs a valid document type declaration to ensure that the web pages are displayed as intended.
While the doctype declaration is usually the first item described in an HTML document (even before the opening html> tag), it is not an HTML tag in itself.
for HTML5 the DOCTYPE is short, concise, and case-insensitive.
Doctypes for older versions of HTML were longer because the HTML language was based on SGML and thus required a reference to a DTD, but they are now obsolete.
This is no longer the case with HTML5, and the doctype declaration is now only required to enable standard mode for documents written in HTML syntax.
You may use the following markup as a guide to building a new HTML5 document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><!-- Insert your title here --></title>
</head>
<body>
<!-- Insert your content here -->
</body>
</html>
Note: A Document Type Definition is referred to by the doctype declaration (DTD). It tells the web browser what version of the markup language the website uses. For all HTML versions, the World Wide Web Consortium (W3C) provides DTDs.
When creating an HTML document, you must include a doctype declaration. Before publishing your HTML online, use the W3C Validator to check for any markup or syntax errors.
- 3 years ago
- Shahzad Gujjar
- 1,977 Views
-
3