A user agent is typically told by the HTTP server (by the "charset" parameter of the "Content-Type" header field) what character set or encoding is used in a web document.
 
If this cannot be done, then a "meta" tag can be used. For example: <meta charset="utf-8"> or <meta http-equiv="Content-Type" content="text/html; charset=utf-8">. This "meta" tag should appear as early as possible in the "head" element. Without this information, a web browser or user agent may need to guess what character encoding was used.

When deciding what encoding to use, it is usually best to use a character encoding that is universal. UTF-8 is the recommended encoding for web documents. Avoid using OS specific or system dependent character encodings, such as those whose name contains "windows", like "windows-1252".

Note that names for character encodings are case-insensitive. For example, "utf-8" and "UTF-8" are both equivalent, and so are "SHIFT_JIS", "Shift_JIS", and "shift_jis".