html - How do browsers handle tag that specifies the character-encoding? -


Suppose that & lt; Meta & gt; Face tag that specifies character encoding:

  & lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" />   

Does this start by re-purging the page, because & lt; Head & gt; The prefix characters of the section can be interpreted incorrectly? Or are there some other obstacles that prevent the first characters from being misinterpreted?

As far as I know, & lt; Head & gt; After getting the Pigment announcement in the browser, the browsers are used to return and they consider ASCII compatible charsets until that point. Unfortunately I can not find any reference to confirm this.

The browser's confirmation will ignore the content-type meta element, if the server already provides the content-type HTTP header, so you can type " The point for the character is for HTML documents, which is not a server by and meta> . HTTP.

This means that You should not rely on an & lt; meta & gt; charset declaration in the HTML file, but configure your HTTP server If you have to rely on & lt; meta & gt; charset announcement for any reason, you only need ASCII characters to that point and it should be sent to & lt; head & Gt; as possible, as the first element.

Comments