2

If a web page has,

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
…
</head>

but the http header has

Content-Type    text/html; charset=UTF-8

Then what encoding is assumed?

ctrl-alt-delor
  • 7,506
  • 5
  • 40
  • 52

1 Answers1

3

In HTML5 the priority is defined as:

  1. User browser setting
  2. Byte order mark
  3. HTTP header
  4. <meta http-equiv="Content-Type"> or <meta charset> depending on attribute order.
  5. Browser default for the locale.

See http://www.w3.org/html/wg/drafts/html/master/syntax.html#determining-the-character-encoding for the gory details.

Alohci
  • 78,296
  • 16
  • 112
  • 156
  • In this answer high is low and low is high (1 is higher priority) – ctrl-alt-delor Feb 18 '13 at 14:51
  • OK looks like Firefox is not broken, but the website I was testing is. I was expecting that the more local setting would win, i.e. the html meta, as it is more likely to know the truth. – ctrl-alt-delor Feb 18 '13 at 14:53
  • 1
    @richard - You'd think so, but that's not the experience of the browser manufacturers. What they find is that the average web author doesn't understand character encodings at all, and will simply cut and paste the meta element from another document resulting in a more or less random value. The HTTP header, for whatever reason turns out to be more reliable. The BOM is a dead give-away, because it's almost invariably written by the same tool and at the same time that the resource is actually character encoded, which is why it ranks so highly. – Alohci Feb 18 '13 at 15:15