Full-stack JavaScript path (17) HTML5 new character set attribute, full-stack javascript path
HTML5 adds several Character Set attributes for documents.
Document. charset: indicates the character set used by the document.
Document. defaultCharset: indicates the default character set, which depends on the browser and operating system settings.
If the document does not use the default character set, the document. charset and document. defaultCharset may be different.
Set the document character set: however, you can use the <meta> element, Response Header, or directly set the charset attribute to modify this value. Let's look at three examples.
- <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
- Document. charset = "utf8 ";
- Res. header (200, {'content-type': 'text/html; charset = UTF-8 '}) // set the Response header for node. js
Browsers that support the document. charset attribute include IE, Firefox, Safari, Opera, and Chrome.
Browsers that support the document. defaultCharset attribute include IE, Safari, and Chrome.