CSS @charset Property
A @charset rule specifies the character encoding of the style rules and values. The @charset rule should never be used in an embedded style sheet, as there are other ways to define character encoding in HTML such as <meta> tag. If several @charset at-rules are defined, only the first one is used, and it cannot be used inside a style attribute on an HTML element or inside the <style> element where the HTML page's character set is relevant.
Initial Value | none |
Applies to | Block-level elements. |
Inherited | No. |
Animatable | No. |
Version | CSS2 |
DOM Syntax | object.style.clear = "UTF-8"; |
Syntax¶
@charset "charset";
Here you can see how @charset can be used in code:¶
@charset "iso-8859-15"; /* Set the encoding of the style sheet to iso-8859-15*/
The following piece of code shows both the right and wrong ways of using the @charset rule: ¶
@charset "UTF-8"; /* Set the encoding of the style sheet to Unicode UTF-8 */
@charset 'iso-8859-15'; /* Invalid, wrong quoting style used */
@charset "UTF-8"; /* Invalid, more than one space */
@charset "UTF-8"; /* Invalid, there is a character (a space) before the at-rule */
@charset UTF-8; /* Invalid, without ' or "*/
Values¶
Value | Description |
---|---|
charset | Specifies the character encoding to use. |
initial | It makes the property use its default value. |
inherit | It inherits the property from its parent's element. |
0 Comments
CAN FEEDBACK
Emoji