Open In App

HTML <meta> charset Attribute

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The HTML <meta> charset attribute specifies the character encoding for the HTML document. It ensures that the browser correctly interprets the characters and symbols on the webpage, commonly set as UTF-8 for universal character support across languages and symbols.

Syntax

<meta charset="character_set">

Attribute Values: It contains the value i.e. character_set which specifies the character encoding for the HTML document.

Values:

  • UTF-8: It specifies the character encoding for Unicode.
  • ISO-8859-1: It specify the character encoding for the Latin alphabet.

Example: In this example we sets the page's character encoding to UTF-8 using the <meta charset="UTF-8"> tag, ensuring correct character interpretation. The page includes a centered heading and discusses the charset attribute.

html
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">

    <title>HTML meta charset attribute</title>

    <style>
        #nav {
            background-color: #187446;
            margin: 0px;
            overflow: hidden;
        }

        #nav ul {
            list-style-type: none;
            margin: 0px;
            float: left;
        }

        #nav li {
            display: inline;
            float: left;
            padding: 15px 10px;
        }

        #nav a {
            color: white;
            font-family: Helvetica, Arial, sans-serif;
            text-decoration: none;
        }

        a {
            position: relative;
        }

        #nav a:after {
            content: '';
            position: absolute;
            top: -10px;
            bottom: -10px;
            left: -10px;
            right: -10px;
        }

        #nav li:hover {
            background-color: lightgreen;
        }

        #nav a:hover {
            color: black;
        }
    </style>
</head>

<body>
    <div id="nav">
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">Data Structure</a></li>
            <li><a href="#">Algorithm</a></li>
            <li><a href="#">Web Technology</a></li>
        </ul>
    </div>
</body>

</html>

Output:

Supported Browsers:

The browser supported by HTML <meta> Charset Attributeare listed below:


Similar Reads