Experience Summary: What exactly does a webpage need to encode?

Source: Internet
Author: User
Tags character set html page
Code | Web page has been to UTF-8 smell without trying, today take a break at noon when the children with 4 HTML files to debug the next.

1, normal HTML page, and declare this HTML file is using gb2312 Character Set

Save as FileName: utf1.html, The code uses ANSI

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Cn-bruce www.cnbruce.com" >
<title>utf-8</title>
<body>
Debugging Utf-8 Code
</body>

In IE, the characters appear normal. If you choose the browser menu "View"-"code"-"except for Simplified Chinese", the page appears garbled.

2, is still plain HTML page, and declares that this HTML file is using gb2312 Character Set

Save as FileName: utf2.html, but the code uses UTF-8


<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Cn-bruce www.cnbruce.com" >
<title>utf-8</title>
<body>
Debugging Utf-8 Code
</body>

In IE, the characters appear normal. Then choose Browser Menu "View"-"encoding"-"Always display Unicode (UTF-8)", the page does not appear any garbled.

3, the same plain HTML page, but declaring this HTML file is using UTF-8 Character Set

Save as FileName: utf3.html, but the code uses ANSI

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<meta name= "Author" content= "Cn-bruce www.cnbruce.com" >
<title>utf-8</title>
<body>
Debugging Utf-8 Code
</body>



IE Browse, character display is garbled. Then choose the browser Menu "View"-"code"-"Simplified Chinese", the page just normal.

4, continue to be plain HTML page, declare this HTML file is using UTF-8 Character Set

Save as FileName: utf4.html, and coding or using the UTF-8


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<meta name= "Author" content= "Cn-bruce www.cnbruce.com" >
<title>utf-8</title>
<body>
Debugging Utf-8 Code
</body>
In IE, the characters appear normal. Then choose Browser Menu "View"-"encoding"-"Always display Unicode (UTF-8)", the page does not appear any garbled.

So now, the individual concludes: from utf2.html and utf4.html comparison, the page display and file used by the character set is not directly related to, it is only a declarative role. The real body is also the encoding format when the file is saved: ANSI Or UTF-8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.