- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - charset Attribute
HTML charset attribute is used for defining the character encoding in the HTML document.
If it is present in the <meta> element, its value must be an ASCII case-sensitive match for the string utf-8, because UTF-8 is only valid encoding for HTML5 documents.
Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters.
You can use this attribute with <meta> as well as <script> tag, but for the script element, the charset attribute is considered as the deprecated attribute. The charset attribute is used with <meta> tag so the specify the character encoding.
In HTML, character encoding is a technique used to convert bytes into characters. It is important to choose the right character encoding for an HTML document to validate or display it properly.
Syntax
<meta charset = "value">
It contains the value i.e character_set which specify the character encoding for the HTML document.
Applies On
Below listed elements allow using of the HTML charset attribute.
Element | Description |
---|---|
<meta> | HTML <meta> tag lets us specify metadata, which is additional important information about a document. |
<script> | HTML <script> The script tag is employed for defining a client-side script for image manipulation, form validation, and dynamic content updates. |
Example of charset attribute in meta tag
In the following example, we are using the charset attribute with the meta tag. When we run the above code, it will generate an output consisting of the text displayed on the wbpage.
<!DOCTYPE html> <html lang="en"> <head> <!--UTF-8--> <meta charset="UTF-8"> <title>HTML 'charset' attribute</title> </head> <body> <!--HTML 'charset' attribute--> <h2>Example of the HTML 'charset' attribute</h2> <p>We are trying to understand the usage of the 'charset' attribute with the help of this program. </p> </body> </html>
Supported Browsers
Attribute | |||||
---|---|---|---|---|---|
charset | Yes | Yes | Yes | Yes | Yes |
To Continue Learning Please Login
Login with Google