HTML !DOCTYPE Web page document file type

 The <!DOCTYPE> tag often seen at the beginning of the HTML webpage source code can be seen from the grammatically literally DOC and TYPE. This tag is used to tell the browser about the type of the DOC of this webpage. Written in the vernacular, it is the file file types of web pages. Because of the development of the Internet, HTML syntax has many different file file formats, and there are also many different HTML versions, such as the earliest HTML, HTML2.0, From HTML 4.01 to the current XHTML, HTML5, XHTML5, etc., web designers can declare the document type of a web page through the <!DOCTYPE> tag, so that the browser can display the content of the web page correctly.


Example of !DOCTYPE tag for HTML page source code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
This way of writing is to declare that the web page is written in HTML 4.01 version formulated by W3C. When the browser sees the content of this <!DOCTYPE> tag, it can present the web page in the most suitable way for this version, but there are also many websites It’s not used like this, but only write <!DOCTYPE html> at the beginning of HTML . Please don’t misunderstand that the designer is lazy. This way of writing is the latest HTML5 DOCTYPE standard document format developed by W3C. Google, Facebook, Yahoo, etc. Almost all the source code of the website of the road giant can be seen.

Declare HTML5 document format example
<!DOCTYPE html>
<html>
<head>
<title>Here is the page title</title>
</head>
<body>
 ... Here is the content of the page...
</body>
</html>
Since the function of <!DOCTYPE> is used to declare the file type of a webpage document, it is usually written directly at the beginning of the source code of the webpage like an example, so that the browser can recognize the webpage you design at the first time. It is very important. If it is written in the relatively later code, some browsers may display garbled characters or typographical errors in the rendering results. When an excellent web designer, write <!DOCTYPE> in The good habit of beginning HTML page source code is still necessary.

Post a Comment

0 Comments