Avoid character set in meta tag AND Specify character set

I have alredy add code in my php webpage for example ...

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 

than after https://developers.google.com/speed suggest for

  • Specify a character set
  • Avoid typing characters in a meta tag
+6
source share
1 answer

Use an HTTP header, not a meta tag. The implementation depends on which server method you are using.

If you are creating your content using PHP, put it at the top of the page:

 header("Content-Type: text/html; charset=utf-8"); 

If you are using any other server-side programming language, there should be a similar option.

Alternatively, if you are using Apache, you can do this using the htaccess directives as follows:

 AddType 'text/html; charset=UTF-8' html 

And if you use nginx, put this in your configuration:

 more_set_headers -t 'text/html' 'Content-Type: text/html; charset=utf-8'; 

Learn more about the avoidance meta tag.

Google dev tools offer to remove meta tags wherever possible, due to the duplication of information that it can cause. Some web servers automatically send content type headers, for example, and in some cases incoherent meta tags can cause browsers to get ... let's say confuse.

To avoid duplication of information and possible headaches associated with the encoding, always prefer headings over meta tags.

+19
source

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


All Articles