Home > Article > Web Front-end > Day 3: Defining Language Encoding_Basic Tutorial
The third step is to define your language encoding, similar to this:
In order to be correctly interpreted by browsers and pass W3C code verification, all XHTML documents must declare the encoding language they use. We generally use gb2312 (Simplified Chinese). It is also possible to use Unicode, ISO- 8859-1, etc., defined according to your needs.
Usually this definition is sufficient. However, it should be added that XML documents do not define language encoding in this way. XML is defined as follows:
You can see similar statements in the first line of code on the homepage of Macromedia.com. This is also the definition method recommended by W3C. So why don't we just adopt this approach? The reason is that some browsers have incomplete support for standards and cannot correctly understand such definition methods, such as IE6/windows. Therefore, under the current transition plan, we still recommend using the meta method. Of course, you can write both ways.
Looking at the source code of this website, you will find that there is one more sentence where the language encoding is defined:
This is written for older browsers to ensure that various browsers can interpret the page correctly.
Note: At the end of the above declaration statement, you see a slash "/", which is different from our previous HTML4.0 code writing. The reason is that XHTML syntax rules require that all tags must have a beginning and an end. For example,
and ,and
, etc. For unpaired identifiers, it is required to add a space at the end of the identifier, followed by a "/". For example,