How to specify the character encoding used in an external script file in HTML5 ?
Last Updated :
17 Mar, 2021
Improve
To specify the character encoding used in an external script file in HTML5 we use <script> charset attribute. The charset attribute specifies the character encoding for the HTML document when used by the <meta> element. The charset attribute specifies the character encoding used in an external script file when used by the <script> element.
Syntax:
<meta charset=""> <script charset="">
Attribute Values: Below are the values which specifies the character encoding for the external scripts.
- ISO-8859-1: Used to specify the Standard encoding for the Latin alphabet.
- UTF-8: Used to specify the Character encoding for Unicode.
Example: Below example illustrates the use of charset attribute using meta tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>GeeksForGeeks</h1>
<p>Write some code....</p>
</body>
</html>
Output:
