Open In App

What is the use of charset Attribute in <meta> Tags ?

Last Updated : 26 Feb, 2024
Like Article

The “charset” attribute in <meta> tags are used to specify the character encoding used by the HTML document. Character encoding determines how characters are represented and interpreted by the browser when rendering the web page. By explicitly defining the character encoding, developers ensure proper text display and avoid encoding-related issues.


<meta charset="character_encoding">
Key Point Description
Character Encoding The “charset” attribute specifies the character encoding used in the HTML document, such as UTF-8, ISO-8859-1, or Windows-1252.
UTF-8 Encoding UTF-8 is the most commonly used character encoding for modern web pages, supporting a wide range of characters from various languages and scripts.
Compatibility Specifying the correct character encoding ensures that text content is rendered accurately across different browsers and devices.
Default Encoding If the “charset” attribute is omitted, the browser may use the default character encoding specified in the HTTP Content-Type header or assume a default encoding such as UTF-8.


  • Basic Usage: Specify the character encoding using the “charset” attribute within the <meta> tag:
  • UTF-8 Encoding: UTF-8 is widely recommended for web pages due to its compatibility with a broad range of characters and languages:
  • Encoding Declaration: Including the “charset” attribute at the beginning of the HTML document ensures that the browser interprets the content correctly from the outset, minimizing encoding-related issues.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads