YouTip LogoYouTip

Att Form Accept Charset

## HTML `
` accept-charset Attribute The `accept-charset` attribute specifies the character encodings that the server accepts and expects for the submitted form data. When a user submits a form, the browser encodes the input data using a specific character set before sending it to the server. By default, the browser uses the same character encoding as the document containing the `` element. The `accept-charset` attribute allows you to override this default behavior and explicitly define which encoding(s) should be used. --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | `character_set` | A space-separated list of one or more character encodings.

**Commonly used values:**
β€’ `UTF-8`: Unicode character encoding (highly recommended for modern web applications).
β€’ `ISO-8859-1`: Character encoding for the Latin alphabet.

*Note: In theory, any character encoding can be used, but browsers may not support obscure encodings. It is best practice to stick to widely adopted standards like UTF-8.* | --- ## Code Examples ### Example 1: Specifying ISO-8859-1 Encoding In this example, the form data will be encoded using the `ISO-8859-1` character set when submitted to the server: ```html



``` ### Example 2: Specifying UTF-8 Encoding (Recommended) UTF-8 supports almost all characters from all written languages, making it the modern standard for web forms: ```html
``` --- ## Differences Between HTML 4.01 and HTML5 * **HTML 4.01:** The `accept-charset` attribute allowed a list of character encodings separated by either spaces or commas (e.g., `accept-charset="UTF-8, ISO-8859-1"`). * **HTML5:** The attribute value must be a **space-separated** list of character encodings. Commas are no longer valid separators. --- ## Best Practices and Considerations 1. **Default Behavior:** If the `accept-charset` attribute is not specified, the default value is the reserved string `"UNKNOWN"`. This tells the browser to match the encoding of the document containing the form. 2. **Universal Standard (UTF-8):** It is highly recommended to use `UTF-8` for both your HTML document encoding (via ``) and your form submissions. This eliminates encoding mismatches and ensures international characters (such as emojis, accented letters, and non-Latin scripts) are transmitted correctly. 3. **Server-Side Configuration:** Ensure that your server-side script (e.g., PHP, Node.js, Python) is configured to decode the incoming request payload using the same character set specified in the `accept-charset` attribute. --- ## Browser Compatibility The `accept-charset` attribute is fully supported by all major modern web browsers: * Google Chrome * Mozilla Firefox * Microsoft Edge / Internet Explorer * Safari * Opera
← Att Form ActionAtt Details Open β†’