How HTML meta charset works

2019-08-06 17:12发布

How does meta charset work? Please correct my understanding if I am wrong. As I understand it, the charset is used as to indicate what encoding the page is to be shown? If I put a very specific encoding, others might not be able to see it displayed correctly. But why? Isn't the encoding set on the meta tage and the browser renders characters based on the charset? Or do I have the wrong idea (probably)?

2条回答
贼婆χ
2楼-- · 2019-08-06 17:45

Letters, numbers and other characters have to represented in computers as bytes.

There are different ways (character encodings) that can be used to represent the same characters. Usually you'll want to use UTF-8 these days.

Meta charset tells the browser which one you have used so it knows how to decode the bytes into characters correctly.

If you tell the browser you are using UTF-8 when you are actually using ISO-8859-1, then you'll get errors (the wrong characters) showing up in places where the encodings do not overlap.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-08-06 17:54

character_set Specifies the character encoding for the HTML document.

In theory, any character encoding can be used, but no browser understands all of them. The more widely a character encoding is used, the better the chance that a browser will understand it.

查看更多
登录 后发表回答