accept-charset

The accept-charset attribute in HTML tells the server which character encodings are supported for form data. When the form is submitted, the browser uses this attribute to encode the data before sending it.

accept-charset attribute

The accept-charset attribute in HTML specifies the character encodings to be used when submitting a form. Placed within a <form> element, it indicates which encodings the server can process for the form data. When the form is submitted, the browser encodes the data with the chosen encoding before sending it to the server.

Syntax

index.html
<form accept-charset="character-set">

If the accept-charset attribute is not specified, the form will use the default charset of the document or browser. It can either be a single charset (e.g., UTF-8) or a list of charsets separated by commas (e.g., accept-charset="UTF-8, ISO-8859-1").

Example

The form accept-charset attribute


index.html
<h1>The form accept-charset attribute</h1>
<form accept-charset="utf-8">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
</form>

Definition and Usage

The accept-charset attribute defines the character encodings to be used when submitting a form. By default, it is set to the reserved value "UNKNOWN," which means the encoding matches the document's encoding containing the <form> element.

This attribute is no longer supported in HTML5.

Values

  • accept-charset
    • A space-separated list of character encodings, such as UTF-8 and ISO-8859-1. By default, it is set to 'unknown', meaning UTF-8 is used for HTML5 pages.

Applies To

The accept-charset attribute can be used with the following element: <form>.

ElementsAttributes
<form>accept-charset

Conclusion

The accept-charset attribute was used to define which character encodings should be used when submitting form data. However, it is no longer supported in HTML5. In HTML5, the default encoding for form submissions is UTF-8.