It is not necessary to include <meta charset="blah">
. As the specification says, the character set may also be specified by the server using the HTTP Content-Type
header or by including a Unicode BOM at the beginning of the downloaded file.
Most web servers today will send back a character set in the Content-Type
header for HTML text data if none is specified. If the web server doesn't send back a character set with the Content-Type
header and the file does not include a BOM and the page does not include a <meta charset="blah">
declaration, the browser will have a default encoding that is usually based on the language settings of the host computer. If this does not match the actual character encoding of the file, then some characters will be displayed improperly.
Will browsers use the proper encoding 99% of the time? If your page is UTF-8, probably. If not, probably not.
The W3C provides a document outlining the precendence rules for the three methods that says the order is HTTP header, BOM, followed by in-document specification (meta tag).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…