HTML Attributes
HTML <form> accept-charset Attribute
The accept-charset attribute specifies the character encodings the server accepts for a submitted form. In modern practice it is almost always UTF-8.
The <form> accept-charset Attribute
The accept-charset attribute belongs to the <form> element. It declares the character encoding, or a space-separated list of encodings, the server will accept when the form data is submitted. By default, forms are submitted using the encoding of the page, so today this is almost always UTF-8.
Syntax
Syntax: <form accept-charset="charset-list">. The value is one encoding name, or several separated by spaces or commas.
<form accept-charset="UTF-8"> ... </form>Example
Run the example to see a UTF-8 encoded application form that safely handles names in any language.
<!DOCTYPE html>
<html>
<body>
<form action="/apply" method="post" accept-charset="UTF-8">
<label for="name">Your name</label><br>
<input type="text" id="name" name="name" placeholder="e.g. Aarav Sharma"><br><br>
<button type="submit">Apply</button>
</form>
</body>
</html>Attribute Values
| Value | Description |
|---|---|
| UTF-8 | Universal Unicode encoding, the recommended default |
| ISO-8859-1 | Legacy Western European (Latin-1) encoding |
| UTF-16 | 16-bit Unicode encoding, rarely used for forms |
| charset list | Multiple encodings separated by spaces, e.g. "UTF-8 ISO-8859-1" |
In nearly all modern sites you should serve pages as UTF-8 (via <meta charset="UTF-8">) and leave accept-charset unset or set to UTF-8 to safely handle names in any language.
Key Takeaways
- accept-charset applies only to the <form> element.
- It lists the character encodings the server will accept on submit.
- UTF-8 is the correct default for virtually all sites.
- Multiple encodings can be listed separated by spaces.
- Pair it with <meta charset="UTF-8"> for consistent handling.
