script charset attribute
The charset attribute on the script element:
!Observations
- charset attribute can be specified only if src attribute is present (for external scripts only)
- the value of the charset attribute is case-insensitive
- if type attribute is present, charset must not be specified
Examples
< | attribute | = | "value(s)" | > | ... | </ | >Examples |
---|---|---|---|---|---|---|---|
2. | charset | = | character encoding name | <src="jsfile.js" charset="UTF-8"> <⁄ > <src="jsfile.js" charset="utf-8"> <⁄ > <src="http://domain.com/jsfile.js" charset="utf-8"> <⁄ > |
Video demonstration script charset attribute
HTML5 script charset attribute, Tutorial
min | video details |
---|---|
00:04 | the charset attribute on the script element allows you to specify the character encoding set of the external script file linked to your HTML5 document |
00:08 | the external script file linked to our HTML5 document: file.js |
00:12 | this means that the charset attribute cannot be specified in the absence of the src attribute |
00:18 | the character encoding set of the external script file, file.js is: UTF-8 |
00:33 | the external script file, file.js, linked to the html page is UTF-8 encoded, aspect specified through the charset attribute |
For more information about W3C
, please see the specs: