HTML charset Attribute

❮ HTML Attributes

Example

<head>
	<meta charset="UTF-8">
	<!-- or -->
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

Meaning

<meta>

The charset attribute is used to set the character encoding for the document like “UTF-8”.

This approach is an alternative to using the http-equiv method currently employed.

<script>

The charset attribute specifies the character encoding used in an external script file. It is used when the character encoding in an external script file differs from the encoding in the HTML document.

Note: The charset attribute is only for external scripts.




Standard Syntax

<element charset="">



Browser Support




Status




Applies to:

The charset attribute can be used on the following element:

Element Attribute
<meta> charset
<script> charset






Attribute Values

Value Description
characterSet Specifies the character encoding for the document. The HTML5 specification recommend to use the UTF-8 character set!



More Examples

Example

<script charset="UTF-8" src="demo-script-charset.js"></script>
❮ HTML Attributes