XHTML Tutorial - head and DTD
Despite the head and DTD not shown on the page, but the web site is an important element.
The handbook after more closely linked, we recommend that you read from the first quarter onwards.
Why wrong?
In the last one we tested in our website we received some wrong information, but we in the process of making Web pages are written in accordance with the standards of XHTML ah. In fact, the problem lies in the web page "head" Below we to solve the problem.
<head> Part
In the previous tutorial, in addition to <title> labels are beyond our revised <body> between the content, which is displayed in the contents of pages. Then in XHTML <head> part is what to do? In fact In "head> Mody part I can join many browsers can" see "message. Below we will introduce some common head of the label.
Note: This section tags and attributes most difficult memories, in fact we use a web authoring software to create Web pages when they will be automatically generated. The aim of this section is to understand the meaning of these labels, when necessary can do some manual modifications. Now open our "index.html" In "head> </ head> intermediate insert the following code:
1. <meta Http-equiv="Content-Type" content="text/html;charset=utf-8" />
This code tells the Web browser we use the utf-8 Chinese character encoding, and the absence of the paragraph <meta> information on a test is a problem when one of the reasons why.
2. <meta Name="keywords" content="小学生,欺负同学,寒暑假作业,家长" />
This code is written for the search engines, content is the content of words index.html.
Please note that <meta> tag is an empty label, not to forget the /. <meta> Label also far from the only role of these, but the lack of practical application in the circumstances it is difficult to understand <meta> labels practical usefulness. If you want to learn more <meta> labels knowledge can go to the Baidu search relevant knowledge.
About <head> Note label
As said before, <head> part of the content is not written for surfers, but for the browser and search engine written. Therefore <head> part, should not be contained in the pages of any visual content.
DTD
If we now re-examination of the website will still get an error message, indicating that no document DTD, then what is DTD documents? Simple that it is in anyone (in most cases is similar to the browser software) to read the documents before we told him that we comply with the document which is a set of rules to write. To test the process, for example, if we use it HTML4.01 the DTD validity of post-mortem will be that we are using the rules of the HTML4.01 prepared by the website, and follow the relevant rules to line by line examination of our code, the eventual return the test results.
We made use of XHTML web of rules, of course, to use the DTD XHTML. However, as we mentioned earlier, the DTD XHTML are also divided into a transitional period of relatively loose DTD and the stringent requirements of a strict DTD. This tutorial we will be in the website statement strict DTD, if you would like to learn more about the contents of DTD need to learn XML, not too much of this tutorial discussion.
Below us on our website statement DTD. Preservation of open before "index.html" in the first line (<html> labels before) Enter the following code:
<DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Strict / / EN"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
。 And In "html> labels, add the following attributes: xmlns =" http://www.w3.org/1999/xhtml. " This is called namespace attributes part of the XML areas, we are still here not too much discussion.
This code is the role of the Web page is the statement we use xhtml1-strict.dtd. This page is then submitted to the W3-tested, this will return to a "This Page Is Valid XHTML1.0 Strict!" Information. This shows that we did not code for any errors, in full compliance with the strict XHTML1 (strict) standards. Of course, the actual work situation may not always be the case, in the actual process of designing the web site, there is always caused by various reasons we write non-standard code. This time will be given for post-mortem error reporting, we need to amend the code in accordance with tips can be.
Enter the next section: XHTML Guide - Forms
