Open In App

How to specify the character encoding used in an external script file in HTML5 ?

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.

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:

Meta Example

Article Tags :