Definition
The accept-charset Attribute specifies the character encoding to be used for a <form> submission.
Applicable Elements
The accept-charset Attribute can be used with the following elements:
HTML <form> accept-charset Attribute
The <form> tag is used to create an HTML form that contains controls for submitting user information.
The accept-charset attribute specifies the space-separated character encodings accepted by the server for the <form> submission.
Syntax
<form accept-charset="UTF-8"></form>Usage
- The
accept-charsetattribute accepts space-separated character encodings. Common values include:UTF-8- Unicode character encoding.ISO-8859-1- Latin alphabet character encoding.
- The recommended character set for HTML5 is Unicode
UTF-8. - The character set for a web page is usually set out in the
<head>using the<meta>tag:If the<meta charset="UTF-8"><form>element does not set anaccept-charsetattribute, it will default to the documents character encoding. For most forms, anaccept-charsetattribute is not required for this reason. - The
accept-charsetattribute is ASCII case-insensitive. - You can specify multiple
accept-charsetencodings separated by a space. The order of the character sets matters. For instance, you may have a preferred set of character encodings if someone types Hebrew letters in your form, but you also want to haveUTF-8as a backup.
Values
The HTML5 recommended value is:
UTF-8
But you can use any character encoding set. See here for a full list.
Examples
The following example shows a form that accepts the UTF-8 character encoding:
<form accept-charset="UTF-8" action="" method="get" class="form">
<fieldset class="fieldset">
<label for="name">Name: </label>
<input type="text" name="name" id="name">
</fieldset>
<div class="form-example">
<input type="submit" value="Subscribe!">
</div>
</form>An example showing multiple accept-charset declarations. The primary encoding is Hebrew, with UTF-8 as secondary:
<form accept-charset="ISO-8859-8 UTF-8" action="" method="get" class="form">
<fieldset class="fieldset">
<label for="name">Name: </label>
<input type="text" name="name" id="name">
</fieldset>
<div class="form-example">
<input type="submit" value="Subscribe!">
</div>
</form>Specification
The accept-charset HTML specification for the <form> element is as follows:
Browser Support
The accept-charset has the following browser support:
Desktop
| Chrome | Edge | Firefox | IE | Opera | Safari | |
|---|---|---|---|---|---|---|
<accept-charset> | Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
| Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet | |
|---|---|---|---|---|---|---|
<accept-charset> | Yes | Yes | Yes | Yes | Yes | Yes |
