Article introduction of Wulin.com (www.vevb.com): The changes in syntax changes in HTML 5 are precisely because there were almost no web browsers that comply with the standard specifications before HTML 5. Next, let's take a look at the tagging method in HTML 5.
The syntax changes in HTML 5 are precisely because there were almost no web browsers that comply with the standard specifications before HTML 5. Next, let's take a look at the tagging method in HTML 5.
1. ContentTypeThe DOCTYPE declaration is essential in the HTML file, and it is located on the first line of the file. In HTML 4, its declaration method is as follows:
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN >In HTML 5, no version declaration is required, and a document will apply to all HTML versions. The DOC TYPE declaration method in HTML 5 (case insensitive) is as follows:
What is DOCTYPE
The <!DOCTYPE> declaration is located at the frontmost position in the document, before the <html> tag. This tag tells the browser which HTML or XHTML specification to use for the document.
<!DOCTYPE htmlPUBLIC -//W3C//DTD XHTML 1.0 Strict//EN>In the above declaration, the root element of the document is declared as html, which is defined in DTD with the public identifier defined as -//W3C//DTD XHTML 1.0 Strict//EN. The browser will understand how to find a DTD that matches this public identifier. If not found, the browser will use the URL after the public identifier as the location to look for the DTD.
This tag can declare three DTD types, representing strict versions, transition versions, and framework-based HTML documents.
HTML 4.01 Strict Version
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN >HTML 4.01 Transition Version
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN >HTML 4.01 based on framework version
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Frameset//EN > <!DOCTYPE html>In addition, when using tools, you can also add STSTEM identifiers to the DOCTYPE declaration method. The declaration method is shown in the following code:
<DOCTYPE HTML SYSTEM about:legacy-compat>In HTML 5, DOCTYPE declaration methods like this are allowed (case insensitive, quotes do not distinguish whether they are single or double quotes).
3. Specify character encodingUse meta elements in HTML 4 to specify the character encoding in the file, as follows:
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />In HTML 5, you can use the <mate> element to directly append the charset attribute to specify character encoding, as shown below:
<meta charset=UTF-8>Both methods work. You can continue to use one of the previous methods, but you cannot use both at the same time.