

If you have a UTF-8 byte-order mark (BOM) at the start of your file then recent browser versions other than Internet Explorer 10 or 11 will use that to determine that the encoding of your page is UTF-8. You can detect any encodings sent by the HTTP header using the Internationalization Checker. If it is, the meta element must be set to declare the same encoding. Note however that, since the HTTP header has a higher precedence than the in-document meta declarations, content authors should always take into account whether the character encoding is already declared in the HTTP header. If you have access to the server settings, you should also consider whether it makes sense to use the HTTP header. (Remember that this means you also need to save your content as UTF-8.) See what you should consider if you really cannot use UTF-8. You should always use the UTF-8 character encoding. It also doesn't matter whether you type UTF-8 or utf-8. It doesn't matter which you use, but it's easier to type the first one. The declaration should fit completely within the first 1024 bytes at the start of the file, so it's best to put it immediately after the opening head tag.

Quick answerĪlways declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes (called a pragma directive). For information about declaring encodings for CSS style sheets, see CSS character encoding declarations. If you need to better understand what characters and character encodings are, see the article Character encodings for beginners.
#Xml text encoding how to#
This article describes how to do this for an HTML file. A character encoding declaration is also needed to process non-ASCII characters entered by the user in forms, in URLs generated by scripts, and so forth. This is not just an issue of human readability, increasingly machines need to understand your data too. If you don't, you risk that characters in your content are incorrectly interpreted. You should always specify the encoding used for an HTML or XML page.

How should I declare the encoding of my HTML file?
