charset property (document, link, meta, ...)
Sets or retrieves the character encoding of the document, a linked document or a script block.
If you want to specify the character encoding of the document:
in HTML5, use the charset property of the meta element,
in other document types, use the httpEquiv property with the value of 'content-type' and content property of the meta element.For details, please see Example 1 and 2 and the page for the doctype element.
To retrieve the character encoding of the document at runtime, use the charset and characterSet properties.
You can find the related objects in the Supported by objects section below.
This property is read/write.
|HTML page for this property: charset|
Sets or retrieves the character set. For more information, see the page for character sets.
Default: this property has no default value.
Example HTML code 1:
This example shows how to set the character encoding of the document in HTML5:
Example HTML code 2:
This example shows how to set the character encoding of the document in document types other than HTML5:
Example HTML code 3:
This example illustrates the use of the charset attribute:
Example HTML code 4:
This example illustrates the use of the charset property:
Did you find this example helpful?
User Contributed Comments