HTML <script> charset Attribute

HTMLWeb DevelopmentFront End Technology

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−


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

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


Updated on 11-Jun-2020 11:16:41