HTML charset attribute: This attribute mainly used for character encoding of an element if it was used by <meta> element. While it is also used in the external script if it was used by the <script> element.
HTML charset attribute
This attribute is having elements like <meta> & <script>.
Syntax:<meta charset=”character_set”>
Charset attributes in <meta>
The charset attribute is present in the meta element. It defines the character encoding for the HTML document.
Supported Browsers
This attribute supports different types of browsers. They are as follows:
- Google Chrome
- Mozilla
- Internet Explorer
- Safari
- Opera
Example: external script of java
<script src="myscripts.js" charset="UTF-8"></script>
Output:
Greek symbols: αβγδεζηθ
The Greek characters display correctly because they are part of the “UTF-8” character set.
Try changing character sets to “ISO-8859-1” (default), “windows-1252” or “UTF-16”.
Example: Character encoding of element
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1>Freshersnow</h1> <p>Place for all programming tutorials...</p> </body> </html>
Output: