HTML5: How to specify the character encoding used in an external script file?
Solution:
HTML Code:
Explanation:
- This HTML code demonstrates how to specify the character encoding used in an external script file using the charset attribute.
- The <script> element is used to include an external JavaScript file indicated by the src attribute.
- The src attribute points to the URL of the external script file, "https://www.w3resource.com/html-css-exercise/basic/solution/async-example.js".
- The charset attribute is added to specify the character encoding used in the external script file, in this case, "utf-8".
- Specifying the character encoding ensures that the browser interprets the script file correctly, especially if it contains non-ASCII characters or characters specific to a certain character encoding.
- Using the correct character encoding is important for ensuring the proper functioning and display of the script content.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.