Latest web development tutorials

HTML script charset attribute

HTML script tags reference manual HTML <script> tag

Examples

Character set of external JavaScript UTF-8:

<script src="myscripts.js" charset="UTF-8"></script>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the charset attribute.


Definition and Usage

charset attribute specifies the character encoding for use in external script file.

When an external script file character encoding and HTML document coding is not the same, it will use charset attribute.


Tips and Notes

Note: charset attribute applies only to external script (only when using the src attribute).


Differences between HTML 4.01 and HTML5

no.


grammar

<script charset="charset">

Property Value

描述
charset 规定外部脚本文件的字符编码。

一些常用的值:

  • "ISO-8859-1" - 拉丁字母表的标准编码
  • "UTF-8" - Unicode 字符编码。与 ASCII 兼容

请参阅我们的 字符集参考手册 ,获得完整的字符集列表。



HTML script tags reference manual HTML <script> tag