语法
@charset "charset";
在这里我们可以看到如何在代码中使用 @charset:
@charset "iso-8859-15"; /* Set the encoding of the style sheet to iso-8859-15*/
以下代码显示了使用@charset 规则的正确和错误方式:
@charset "UTF-8"; /* Set the encoding of the style sheet to Unicode UTF-8 */ @charset 'iso-8859-15'; /* 无效,使用了错误的引用方式 */ @charset "UTF-8"; /* 无效, 多余一个空格 */ @charset "UTF-8"; /* 无效, 在规则前多了一个空格 */ @charset UTF-8; /* 无效, 没有 ' 或者 "*/
CSS @charset 属性值说明
值 | 说明 |
---|---|
charset | 指定要使用的字符编码。 |
initial | 它使属性使用其默认值。 |
inherit | 它从其父元素继承属性。 |
@charset 规则指定样式规则和值的字符编码。
@charset 规则永远不应该用于嵌入的样式表,因为还有其他方法可以在 HTML 中定义字符编码,例如 <meta> 标签。
如果定义了多个@charset规则,则仅使用第一个,并且不能在 HTML 元素的样式属性内或者与 HTML 页面字符集相关的 <style> 元素内使用。
初始值 | none |
---|---|
应用于 | 块级元素。 |
继承 | 无效 |
可动画的 | 无效 |
版本 | CSS2 |
DOM 语法 | object.style.clear=“UTF-8”; |
日期:2020-06-02 22:14:21 来源:oir作者:oir