HTML / CSS / JavaScript Tutorial

HTML Standard attribute: charset

[this page | pdf | back links]

The HTML charset attribute specifies the character encoding to use. It applies to <meta> and <script> elements.


Common values for this attribute include:


-        UTF-8: the character encoding for Unicode

-        ISO-8859-1: the character encoding for the Latin alphabet


It can be overridden for a specific element by setting the lang attribute of that element. The charset attribute is new in HTML 5 and replaces the need to set the content type via HTML such as: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> (although using the http-equiv approach is still allowed).


Valid attribute values (when used with <meta> and <script> elements) include:





The character encoding for the document


Contents | Prev | Next | HTML Attributes

Desktop view | Switch to Mobile