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:
Examples
Meta Example
Specify the character encoding for the HTML document:
<head>
<meta charset="UTF-8">
</head>
<meta charset="UTF-8">
</head>
Script Example
An external JavaScript with an UTF-8 character set:
<script src="myscripts.js" charset="UTF-8"></script>
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 |
Comments
Post a Comment