Declaring character encodings in HTML
eot; include($pathtophp.'/bp3/structure.php'); ?> xmlns="http://www.w3.org/1999/xhtml">CSS coders, Web project managers, and anyone who wants to know how to declare the character encoding of a CSS file.
How do I declare the character encoding of a CSS style sheet?
It is a good idea to always declare the encoding of external CSS style sheets if you have any non-ASCII text in your CSS file. For example, you may have non-ASCII characters in font names, in values of the content property, in selector values, etc.
For style declarations embedded in a document, @charset rules are not needed and must not be used. These rules are for use in linked style sheets only.
To set the character encoding inside the style sheet, use the @charset "at-rule". Its syntax is:
@charset "<IANA-defined-charset-name>";
Only one @charset rule may appear in an external style sheet and it must appear at the very start of the document. It must not be preceded by any characters, not even comments. (However, a byte-order mark is OK for a document in one of the Unicode encodings.)
The name must be a charset name as described in the IANA registry. The IANA registry commonly includes multiple names for the same encoding. In this case you should use the name designated as preferred. For example to label your CSS file as UTF-8 encoded you would write:
@charset "UTF-8";
You can also declare the encoding of the file in the HTTP Content-Type header, if you have a means to do so. For more information about how to set the encoding in HTTP see Setting the HTTP charset parameter. For example, this line in the HTTP response would indicate that the file is encoded in UTF-8.
Content-Type: text/html; charset=UTF-8
We recommend that if you use an HTTP declaration, you also include a declaration inside the style sheet. This will ensure that the encoding is still known if the style sheet is used locally or moved, eg. for testing or editing.
The declaration in the HTTP header will always override the in-document declaration, if there is a conflict.
The HTML 4.01 specification describes a charset attribute that can be added to the link element and is supposed to indicate the encoding of the document you are linking to. The use of this attribute on a link element is currently deprecated by the HTML5 specification, however, so you shouldn't use it. Actually the charset attribute declaration is not supported by all browsers anyway, so that is another reason to avoid it.