HTML <script> charsetAttribute

HTML script 标签参考手册HTML <script> Tag

Examples

External JavaScript with the UTF-8 character set:

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

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the charset attribute.


Definition and Usage

The charset attribute specifies the character encoding used in an external script file.

The charset attribute is used when the character encoding in an external script file differs from that in the HTML document.


Tips and Notes

Note:The charset attribute only applies to external scripts (only when the src attribute is used).


Differences Between HTML 4.01 and HTML5

None.


Syntax

<script charset="charset">

Attribute Values

Value Description
charset Specifies the character encoding of the external script file.

Some common values:

  • "ISO-8859-1" - Standard encoding for the Latin alphabet
  • "UTF-8" - Unicode character encoding. Compatible with ASCII

Please refer to ourCharacter Set Reference Manual, to obtain a complete list of character sets.



HTML script 标签参考手册HTML <script> Tag Other Extensions