Document: characterSet property

The Document.characterSet read-only property returns the character encoding of the document that it's currently rendered with.

Note: A "character set" and a "character encoding" are related, but different. Despite the name of this property, it returns the encoding.

Value

A string.

Examples

html
<button onclick="console.log(document.characterSet);">
  Log character encoding
</button>
<!-- displays document's character encoding in the dev console, such as "ISO-8859-1" or "UTF-8" -->

Specifications

Specification
DOM Standard
# ref-for-dom-document-characterset①

Browser compatibility

BCD tables only load in the browser