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.
The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!
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 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.