Reasons and solutions for garbled html web pages
Foreword: When using HTML CSS for web page layout, various garbled problems often occur when browsing web pages. So if we need to solve this problem, we need to first understand the cause of the problem. This article will analyze the various causes and solutions for everyone. Everyone is welcome to comment below, thank you!
Recommended video tutorial: HTML tutorial
一、Cause of garbled characters
1, If the source code of the web page is written by gbk
, and the text in the content is utf-8
, then, open it at this time HTML garbled characters will appear in the browser. On the contrary, garbled characters will also appear.
2, the HTML webpage encoding is gbk
, but the program calls out the content encoded in utf-8
from the program library. It will cause garbled encoding.
3. The browser cannot automatically detect the encoding of the web page, causing the web page to be garbled.
2. Methods to solve garbled characters
The first: HTML web page source code encoding and Chinese characters The input encoding is different.
Solution: Use professional editing software to write HTML web pages. For example DW.
Try not to use Notepad directly for writing.
Second : The web page setting encoding is gbk
, but the database storage data encoding format is UTF-8
. At this time, the program queries The database data display data can be transcoded.
For example:
mysql_query("SET NAMES 'UTF-8'") //将查询数据转码为UTF-8
Then don’t forget the following content when making a web page:
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
Third Category: The browser causes garbled characters
This reason is generally caused by the web page not setting the meta charset
encoding. As a result, the browser cannot recognize the default encoding type of your web page.
Solution:
1. If the web page is garbled when browsing in the browser, find the menu to convert the encoding in the browser.
2. If you develop your own web page, you must add the meta charset
encoding tag to the web page.
<meta http-equiv="Content-Type" content="text/html";charset="UTF-8" />
If the conversion is done without editing the meta
charset
encoding tag in Notepad, which will also cause garbled characters, it is because directly adding or adding in Notepad After the encoding format is modified, the corresponding HTML hypertext document content does not change with the addition or modification of the encoding format. At this time, true transcoding is required, so it is best to use professional development software to write the code.
More HTML practical tutorials: HTML practical tutorial
The above is the detailed content of Reasons and solutions for garbled html web pages. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solution to garbled word page numbers: 1. Open the word document and click the "File" option in the upper left corner; 2. Select the "More" option, and then click the "Options" button; 3. Select "Advanced" in the word options; 4. . Find "Show field codes instead of field values" in "Show document content", remove the check in front, and click OK to return to the home page.

The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

Solutions to garbled tomcat startup: 1. Modify Tomcat's conf configuration file; 2. Modify the system language; 3. Modify the command line window encoding; 4. Check the Tomcat server configuration; 5. Check the project encoding; 6. Check the log file; 7 , try other solutions. Detailed introduction: 1. Modify Tomcat's conf configuration file, open Tomcat's conf directory, find the "logging.properties" file, etc.

In the Windows 10 system, garbled characters are common. The reason behind this is often that the operating system does not provide default support for some character sets, or there is an error in the set character set options. In order to prescribe the right medicine, we will analyze the actual operating procedures in detail below. How to solve Windows 10 garbled code 1. Open settings and find "Time and Language" 2. Then find "Language" 3. Find "Manage Language Settings" 4. Click "Change System Regional Settings" here 5. Check the box as shown and click Just make sure.

Solution to Chinese garbled characters in Linux tty: 1. Download the font fbterm through the "sudo apt-get install fbterm" command; 2. Execute the "sudo fbterm" command; 3. Change the font and font size to "font-names=Ubuntu Mono font- size=14” is enough.

How to solve the problem of garbled text documents in win11? When many users use the win11 system, text documents are garbled and cannot be read normally. Many friends do not know how to solve this problem. In fact, this method is not difficult. Below, the editor has compiled the steps to solve the problem of garbled Windows 11 system documents. I hope it can bring you some inspiration! Steps to solve garbled Windows 11 system documents: 1. First, open the control panel of win11, enter control panel in the search box below, and click Search to enter the control panel. 2. After entering the panel, find the clock and area and click to enter, then click on the area option. 3. After entering, click on the management panel, and then click on Change system regional settings.

When many users use computers, they will find that there are many files with the suffix dll, but many users do not know how to open such files. For those who want to know, please take a look at the following details. Tutorial~How to open and edit dll files: 1. Download a software called "exescope" and download and install it. 2. Then right-click the dll file and select "Edit resources with exescope". 3. Then click "OK" in the pop-up error prompt box. 4. Then on the right panel, click the "+" sign in front of each group to view the content it contains. 5. Click on the dll file you want to view, then click "File" and select "Export". 6. Then you can

Solutions to filezilla garbled characters include: 1. Check the encoding settings; 2. Check the file itself; 3. Check the server configuration; 4. Try other transfer tools; 5. Update the software version; 6. Check for network problems; 7. Seek technical support. To solve the problem of FileZilla garbled characters, you need to start from multiple aspects, gradually investigate the cause of the problem, and take corresponding measures to repair it.
