Although head and DTD are not displayed on the page, they are important elements of the web page.
In the previous section, we got an error message when checking our web page, but we wrote it according to the XHTML standard throughout the web page production process. In fact, the problem lies in the head of the web page, so let’s solve this problem below.
In the previous tutorial, except for the <title> tag, we modified the content between <body>, that is, the content displayed on the page. So what does the <head> part in XHTML do? In fact, in the <head> section, I can add many information that can be seen by browsers. Below we will introduce some commonly used tags in the head part.
Note: Most of the tags and attributes in this section are difficult to remember, but in fact they will be automatically generated when we use web page creation software to create web pages. The purpose of this section is to understand the meaning of these tags so that some manual modifications can be made when necessary. Now open our index.html and insert the following code in the middle of <head></head>:
| 1.<meta http-equiv=Content-Type content=text/html;charset=gb2312 /> |
This code tells the browser that our web page uses gb2312 Chinese character encoding. The lack of this <meta> information is one of the reasons for the problem during the last check.
| 2.<meta name=keywords content=primary school students, bullying classmates, winter and summer homework, parents/ |
This code is written for search engines, and the content of the content is the keyword index.html.
Please note that the <meta> tag is also an empty tag, don't forget to add /. The function of <meta> tags is far more than that, but in the absence of practical applications, it is difficult to understand the actual use of <meta> tags. If you want to know more about the <meta> tag, you can search for relevant knowledge on Baidu.
As mentioned earlier, the content of the <head> part is not written for the browser, but for the browser and search engine. Therefore, the <head> part should not contain anything visible in the page.
If we check our web page again now, we will still get an error message, prompting that the DTD file cannot be found, then what is a DTD file? Simply put, it is to tell anyone (mostly browser-like software) that the file is written according to which set of rules we have written before they want to read it. Taking the inspection process as an example, if we use HTML4.01 DTD, the verification device will think that we are a web page written using HTML4.01 rules, and then verify our code line by line according to the corresponding rules, and finally return the test result.
The web page we make is a rule that uses XHTML, and of course we need to use XHTML DTD. However, as we mentioned earlier, XHTML's DTD is also divided into relatively loose transition DTD and quite strict DTD. In this tutorial, we will declare strict DTD on the web page. If you want to learn more about DTD, you need to learn XML, so you will not discuss it too much in this tutorial. 2 pages in total Previous page 12 Next page