Can I declare two different charsets on one HTML page using a meta tag?

二次信任 提交于 2019-12-06 04:08:02

问题


Is possible to specify two different character sets on a page using meta tags, like:

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

I tried to add both of them and doesn't work :P

Thanks


回答1:


No, it's not possible. What would be the point of adding two different charset declarations? You should add only one declaration that matches your content.




回答2:


A "character set" is better referred to in this context as a "text encoding". Text is stored by computers as numbers. For a given piece of stored text, the encoding is the thing that defines which characters are represented by which numbers.

Because HTML is text, in order to display it, the browser needs to know what encoding the text is in. You therefore can't use two encodings in one HTML page, because one HTML page is one lump of text, and the declared encoding applies to all of it.

As @TomasMarkauskas has explained, the UTF-8 encoding can represent all characters that ISO-8859-1 can (and some characters than ISO-8859-1 can't). So you'll want to use UTF-8 for your HTML pages.



来源:https://stackoverflow.com/questions/5542505/can-i-declare-two-different-charsets-on-one-html-page-using-a-meta-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!