English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The charset attribute specifies the character encoding used in the external script file. When the character encoding of the external script file is different from the character encoding of the HTML document, use the charset attribute.
With UTF-8External JavaScript for character set:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML: Use of charset Attribute in script>-Basic Tutorial Website (www.3codebox.com)</<title> </<head> <body> <script charset="UTF-8"src="demo_script_charset.js"></script> Greek characters are displayed correctly because they are "UTF-8" is part of the character set.</p> Attempt to change the character set to "ISO-8859-1(Default)-1252"or"UTF"-16”。</p> </body> </html>Test it out ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the charset attribute.
The charset attribute specifies the character encoding used in the external script file.
Use the charset attribute when the character encoding of the external script file is different from the character encoding of the HTML document.
Note:The charset attribute applies only to external scripts (only when the src attribute is used).
None.
<script charset="charset">
Value | Description |
---|---|
charset | Specifies the character encoding of the external script file. Some commonly used values:
Please refer to our Character Set Reference Manual,for a complete list of character sets. |