Different kinds of Doctype available in HTML5
In this article, we will know the Doctype & its types in HTML5. Before learning the different kinds of Doctypes in HTML5, you should be first familiar with the term “Doctype“. When you inspect any website, you may have noticed that before the starting of <html> tag, <!DOCTYPE html> is written.
Doctype: A Doctype or Document Type Declaration is basically the first line of code that is required when you create an HTML document. It tells the browser about the specific HTML version in which the current web page is written. All the different web browsers will render the webpage using the same version of HTML and therefore the web page will look the same in the different web browsers. This is the main intent of using the Doctype in HTML.
Note: The Doctype is not an HTML tag or element and it’s case-insensitive.
Types: In the previous versions of HTML, there were different kinds of Doctypes that were declared in each version of HTML, but in HTML5 there is only one type of Doctype available.
Usage: In previous versions of HTML, the main usage of Doctype was to create a reference to DTD (Document Type Definition) and it was compulsory to refer to DTD but in HTML5, it doesn’t need to refer to DTD. The Document Type Definition (DTD) was majorly used to define the structure with a list of validated attributes and elements.
Syntax: Nowadays, most of the webpages are created using HTML5, so for that, we just need to create a simple doctype syntax. The following is the syntax of Doctype:
Approach: We just need to declare the Doctype as shown in the syntax at the beginning of the HTML Code.
Example: This example shows a simple HTML code with the declaration of Doctype.
- Google Chrome
- Internet Explorer
- Microsoft Edge
Please Login to comment...