Heim > Web-Frontend > HTML-Tutorial > DOCTYPE HTML

DOCTYPE HTML

WBOY
Freigeben: 2024-09-04 16:45:43
Original
1214 Leute haben es durchsucht

The following article provides an outline of DOCTYPE HTML. In html document type is used to declare the user instructions and convert the data into the web browsers using markup languages like html, xml coding itself. We have declared the document types as the initial steps of the documents. Generally, DOCTYPE does not consider any tag, element, or attributes; it helps identify the markup languages’ version. tag is the root tag or element of the html markup languages. It also helps to store and hold all the web contents, and also it will tell the user browsers to identify whether it’s an html language or not but using on the same web browsers displayed by which version of the html language used by the user web documents.

What is DOCTYPE HTML?

  • A DOCTYPE is nothing but a document type declaration that is a set of instructions that has to be associated with the particular html, xml or sgxml web documents.
  • It is more required for some legacy reasons if the developer omitted the DOCTYPE, then the web browsers will tend to use the different types of rendering modes that may not be compatible with some browsers specifications as well as user applications.
  • It also noted as a null element that does not contain the closing tag, so we cannot include any logic contents inside the .
  • We use declaration in the HTML 4.01 version it also refers to the same Document Type Declaration because HTML 4.01 version is based on the SGML but in HTML5 is not based on the SGML language.

Syntax:

When we use HTML or any markup language, we have a set of syntax for each tag and elements, same as in document type declaration.

Below is the basic syntax for declaring the model in the html documents.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
---Some Front End logic ,codes,tags,elements---
</body>
</html>
Nach dem Login kopieren

Why do we use DOCTYPE HTML?

  • Because it is needed for the Html version and suppose if the user application has any issues at that time, we easily identified the root because it really happened in the HTML version compatibility or user browsers compatibility; also, some html tags can be deprecated when it compares to the current and previous versions.
  • So the user easily identified the issues based on the web applications workflows.
  • In HTML, W3C is the one of the organization like IETF, and also each html pages have the “OwnerID” is a unique label it indicates the name of the html entity or the organizations that is responsible for creating or maintaining the DTD based documents.
  • The DTD is also called “Public Text Class”, which is the type of objects which also referenced with the html tags and elements that have to be followed with web and browser support.
  • It will be supported with both HTM/XHTML DTD.

Different Version of HTML where we use DOCTYPE in HTML?

  • If we use strict as a DOCTYPE, it does not allow the presentational attributes to be written with the html elements while we needed the requirement as in web application and also, it does not support the inclusion of the html frames.
  • Html 4.0 have both strict and transitional DOCTYPE.
  • In strict DOCTYPE, the user will use certain html elements and attributes, while they are not allowed and permitted to be used in the strict DOCTYPE as strict users.
  • Sometimes html 4.0 version supports frameset, and every html documents must have created the above three document type declarations on the web page.
  • If we use html strict, then the document type includes all html elements, attributes except the deprecated elements or tags that are not accepted. Those set of tags and elements will appear in a frameset.
  • If we use html transitional, it also supports all the html elements, including deprecated tags/elements.
  • In html frameset, it supports all the html elements that we used in the html transitional dtd as well as used to declared the frameset.
  • In html 5 supports only one declaration types we use this declaration only allowed for the html 5 versions, but in html 4, we will use a different version of the dtd specifications.
  • In HTML, the DOCTYPE is case insensitive, so we use DOCTYPE declaration, and it will be written as both lower and upper case letters.

Examples of DOCTYPE HTML

Given below are the examples:

Example #1

Code:

<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
</head>
<body>
<p>Welcome To My Domain
</p>
</body>
</html>
Nach dem Login kopieren

Output:

DOCTYPE HTML

Example #2

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Sample Example for Strict DTD </title>
</head>
<body>
<a href><h1>Please Click </h1></a>
<marquee> Welcome To My Domain </marquee>
</body>
</html>
Nach dem Login kopieren

Output:

DOCTYPE HTML

Example #3

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title> Frameset DTD Example </title>
</head>
<frameset cols="23%,*,43%">
<frame src="first.html">
<frame src="second.html">
<frame src="third.html">
</frameset>
</html>
Nach dem Login kopieren

Output:

DOCTYPE HTML

In the above set of examples, we will see the sample and basic dtd usages in html. In the first example, we use the that is come under the html5 version. So we use normal and basic html codings. In the second example, we use strict dtd in html 4 version so it will accept the particular tags and elements; it will not be allowed to use the deprecated tag elements in the second example, but in the last example, we use the frameset dtd in the html documents it allows the deprecated elements as well as whatever we use the html 4 transitional dtd elements and also will include the frameset tag elements.

Conclusion

In html will use DOCTYPE as a better choice for creating the web-based applications, and also it will be helpful for the website users browsers that the document is related to the html based documents. If we suppose will not use the html tag elements in the inside of the document that should be with the DOCTYPE declaration, it must be must with the html standards with the help of web browsers, and templates will check the html standards.

Das obige ist der detaillierte Inhalt vonDOCTYPE HTML. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Quelle:php
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage