HTML Attributes
HTML <form> accept-charset Attribute
The accept-charset attribute specifies the character encodings the server accepts for a submitted form.
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 in modern practice 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 action="/apply" method="post" accept-charset="UTF-8">
<input type="text" name="name" placeholder="Your name">
<button type="submit">Apply</button>
</form>| 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.
