In order to define charset for HTML5 Doctype, which notation should I use?
Short:
While not contesting the other answers, I think the following is worthy of mentioning.
http-equiv
) notation and the “short” one are equal, whichever comes first wins;<meta>
tags;You can test by running echo 'HTTP/1.1 200 OK\r\nContent-type: text/html; charset=windows-1251\r\n\r\n\xef\xbb\xbf<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta charset="windows-1251"><title>привет</title></head><body>привет</body></html>' | nc -lp 4500
and pointing your browser at localhost:4500
. (Of course you will want to change or remove parts. The BOM part is \xef\xbb\xbf
. Be wary of the encoding of your shell.)
Please mind that it's very important that you explicitly declare the encoding. Letting browsers guess can lead to security issues.
There is some news based on Mozilla Foundation, and sitepoint
Do not use this value (
http-equiv=content-type
) as it is obsolete. Prefer thecharset
attribute on the <meta
> element.
To embed a signature on an email, I would use the long version:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The reason is that not many email readers use html5, so it's always better use old html styles. Actually, it's better to use tables than divs + css as well.