HTML accept-charset Attribute

Last Updated : 23 May, 2026

The accept-charset attribute in HTML is used to specify the character encodings for form submission. It helps the server correctly interpret the text entered in the form.

  • Defines the character encoding used when submitting form data.
  • Commonly uses UTF-8 encoding.
  • Helps ensure proper handling of special characters and different languages.

Syntax:

<form accept-charset="UTF-8">
<!-- form elements -->
</form>

Attribute Value: The attribute value contains the list-separated value of one or more encoding attributes. The common value of the encoding attribute is UTF-8, ISO-8859-1. This attribute is always associated with the form element only. 

Example: Using the accept-charset attribute within a form. It specifies "UTF-8" as the character encoding for data submission, ensuring proper handling of text inputs.

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>accept-charset attribute</title>
    <style>
        h1 {
            color:green;
        }
        body {
            text-align:center;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>accept-charset Attribute</h2>
<!--Driver Code Ends-->

    <form action="#" accept-charset="UTF-8">
        First name:<input type="text" 
                          name="fname">
        <br>
        Last name:<input type="text" 
                         name="lname">
        <br>
        <input type="submit" 
               value="Submit">
    </form>

<!--Driver Code Starts-->
</body>

</html>
<!--Driver Code Ends-->
Comment