HTML charset Attribute
Definition and Usage
When used by the <meta> element, the charset attribute specifies the character encoding for the HTML document.
When used by the <script> element, the charset attribute specifies the character encoding used in an external script file.
Applies to
The charset attribute can be used on the following elements:
| Elements | Attribute |
|---|---|
| <meta> | charset |
| <script> | charset |
Examples
Meta Example
Specify the character encoding for the HTML document:
<head>
<meta charset="UTF-8">
</head>
Try it Yourself »
Script Example
An external JavaScript with an UTF-8 character set:
<script src="myscripts.js" charset="UTF-8"></script>
Try it Yourself »
Browser Support
The charset attribute has the following browser support for each element:
| Element | |||||
|---|---|---|---|---|---|
| meta | Yes | Yes | Yes | Yes | Yes |
| script | Yes | Yes | Yes | Yes | Yes |

