HTML

The charset attribute of the <script> element is used to set character encoding, which is used in an external script file.

Following is the syntax−

<script charset="charset">

Above, set charset, which is the character encoding to be used in an external script file. With “UTF-8”, you can set the character encoding for Unicode. Let us now see an example to implement the charset attribute of the <script> element−

Example

<!DOCTYPE html>
<html>
<body>
<script charset="UTF-8" src="new.js"></script>
<p>Displaying the characters with "UTF-8" character set.</p>
<p>.</p>
</body>
</html>

Above, we have used a script file “new.js”, which displays the symbols.

Output

Arjun Thakur
Updated on: 11-Jun-2020

85 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements