Content Type and HTML Encoding

I run the site and I set its content type to use UTF-8 encoding. I also use HTML encoding for special characters, i.e. Instead á, I have á.

Now I wonder (still starting the site) if it really is necessary to do both things. Looking for an answer, I found this:

http://www.w3.org/International/questions/qa-escapes.en.php

It says that I do not use HTML encoding for any special characters, but for >, <and &. But the reason is he runs away

can make it difficult to read and maintain source code, and also significantly increase file size.

I think this is true, but a very bad argument. Is this ONLY USING ESCASIONS and special characters?

+3
source share
1 answer

The article is actually correct. If you have the correct UTF-8 encoded data, there is no reason to use HTML objects for special characters on regular web pages anymore.

I say “on regular web pages” because there are very exotic border scenarios where using entities is still the safest bet (for example, when serving JavaScript code to an external page with an unknown encoding). But this does not apply to serving pages in a browser.

+9
source

Source: https://habr.com/ru/post/1764668/


All Articles