charset attribute (a, link, meta, script)
Sets 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 attribute of the meta element,
in other document types, use the http-Equiv attribute with the value of 'content-type' and content attribute of the meta element.
For details, please see Example 1 and 2 and the page for the !DOCTYPE element.JavaScript page for this attribute: charset. You can find other example(s) there. |
Possible values:
Sets the character set. For more information, see the page for character sets.
Default: this attribute has no default value.
Example HTML code 1:
This example shows how to set the character encoding of the document in HTML5:
|
|||
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> </head> <body> </body> </html> |
|||
|
|||
Did you find this example helpful?
|
Example HTML code 2:
This example shows how to set the character encoding of the document in document types other than HTML5:
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> </body> </html> |
|||
|
|||
Did you find this example helpful?
|
Example HTML code 3:
This example illustrates the use of the charset attribute:
|
|||
<script type="text/javascript" src="example.js" charset="utf-8"></script> |
|||
|
|||
Did you find this example helpful?
|
Supported by tags:
External links:
User Contributed Comments