Solution: 1. Open the html file in the software, select "Modify" - "Page Properties" at the top of the page, select "Title/Encoding" in the new window, select the specified encoding, and click "Apply" and "OK" is enough. 2. Do not use Notepad to edit html code directly.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. Mixed content of different encodings: HTML garbled codes are caused by html encoding problems (common gb2312 and utf-8 encoding contents exist at the same time)
2. HTML encoding is not set: Not set, the setting here is utf-8
3. Use Notepad to edit html: Using Notepad to edit html directly can easily result in html encoding garbled code
1. HTML encoding is not set
htmlNo encoding declaration tag
After opening the HTML in the DW software, in the "code" or "split" mode (this way you can see the code Encoding statement appears), click "Modify" and then click "Page Properties"
Select "Title/Encoding" in the pop-up "Page Properties" tab, and then correspond Select the required encoding value in "Encoding" on the right.
Select html encoding screenshotAfter selecting HTML encoding, click "Apply" and finally "OK" Apply the selected HTML encodingFollow the above steps to add the encoding statement to HTML.#html coding to add the above screenshot
html No coding to add coding using DW software. Under normal circumstances, do not manually add this line of encoding declaration label in Notepad, otherwise it is likely that the entire html encoding has not changed with the addition of encoding, and the html garbled problem will still exist.
2. Notepad editing html
Generally avoid garbled characters. Remember not to use Notepad directly to edit Html code, because it is easy to cause coding problems and lead to garbled Chinese html, especially the original HTML is encoded in UTF, and after adding Chinese characters or codes in Notepad, garbled characters appear when saving. This is because Notepad directly modifies the code, especially after adding Chinese. The added part is gbk encoded content, while the original content is utf encoded. If the two encoded contents exist at the same time in an Html, it will cause garbled code. Although we cannot distinguish the encoding with the naked eye, this encoding format pattern does exist, so the solution to the problem of garbled encoding is to use DW software to edit and modify it. This can greatly reduce the problem of garbled characters. (How to choose gb2313 utf-8) Recommended learning:
html video tutorial######The above is the detailed content of How to deal with garbled Chinese characters in html5. For more information, please follow other related articles on the PHP Chinese website!