charset

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 Valuenone
Applies toBlock-level elements.
InheritedNo.
AnimatableNo.
VersionCSS2
DOM Syntaxobject.style.clear = “UTF-8”;

Syntax

Syntax

@charset "charset";

Here you can see how @charset can be used in a 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

Values

ValueDescription
charsetSpecifies the character encoding to use.
initialIt makes the property use its default value.
inheritIt inherits the property from its parents element.
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部