HTML accept-charset Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Forms & Encoding

What You’ll Learn

The accept-charset attribute is an essential part of HTML forms that determines which character encodings the server may use when processing submitted form data. By setting it, you help ensure text—including accented letters and non-Latin scripts—is interpreted correctly on the server.

01

Form Encoding

Control submitted charset.

02

UTF-8 Default

Modern web standard.

03

Legacy Encodings

ISO-8859-1, Shift_JIS.

04

form Element

Where it applies.

05

acceptCharset

JavaScript DOM property.

06

vs meta charset

Document vs form data.

Purpose of accept-charset

The primary purpose of the accept-charset attribute is to define the character encodings that the server accepts for form submissions. This is crucial for ensuring the server can correctly interpret and handle the data sent from the form—especially when users enter international characters.

💡
Form Submission Only

accept-charset affects how field values are encoded when the form is submitted. It does not change how the HTML page itself is decoded—that is controlled by <meta charset> or the HTTP Content-Type header.

📝 Syntax

Add accept-charset to a <form> element with one or more encoding names separated by spaces:

accept-charset.html
<form action="/submit" method="post" accept-charset="UTF-8">
  <!-- form fields -->
</form>

Syntax Rules

  • Only valid on the <form> element.
  • Separate multiple encodings with spaces (not commas).
  • In JavaScript, use the camelCase property acceptCharset.
  • If omitted, the form uses the document’s character encoding (typically UTF-8).

💎 Values

The accept-charset attribute accepts a string representing one or more character encodings. Common values include:

  • UTF-8 — The most widely used encoding, supporting characters from virtually every language. Use this for all modern sites.
  • ISO-8859-1 — A legacy encoding for Western European languages.
  • Shift_JIS — Used for Japanese text in older systems.
  • UTF-8 ISO-8859-1 — Space-separated list when multiple encodings are accepted.
encoding-values.html
<!-- Single encoding (recommended) -->
<form accept-charset="UTF-8">...</form>

<!-- Multiple encodings -->
<form accept-charset="UTF-8 ISO-8859-1">...</form>

⚡ Quick Reference

Use Caseaccept-charset ValueNotes
Modern websitesUTF-8Default choice
Western European legacyISO-8859-1Older systems only
Japanese legacyShift_JISLegacy compatibility
Multiple optionsUTF-8 ISO-8859-1Space-separated
JavaScript propertyform.acceptCharsetcamelCase in DOM
Applicable element<form>Form only

⚖️ accept-charset vs meta charset

Featureaccept-charsetmeta charset
Applies toForm submission dataHTML document bytes
Element<form><meta> in <head>
When it takes effectOn form submitWhen page loads
Typical valueUTF-8UTF-8

Applicable Elements

ElementSupported?Notes
<form>YesPrimary and only standard use
<input>NoSet on the parent form instead
<textarea>NoInherits form encoding on submit

Examples Gallery

UTF-8 forms, dynamic encoding switches, and multiple accepted charsets.

👀 Live Preview

Form with accept-charset="UTF-8" for international text:

Example — UTF-8 Form

Here’s a basic example illustrating how to use the accept-charset attribute in an HTML form:

accept-charset.html
<form action="/submit" method="post" accept-charset="UTF-8">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email">
  <input type="submit" value="Submit">
</form>
Try It Yourself

How It Works

In this example, the accept-charset attribute is set to UTF-8, indicating that form data should be encoded using UTF-8 when submitted to the server.

Dynamic Values with JavaScript

Similar to other HTML attributes, accept-charset can be dynamically modified using JavaScript based on user interaction or locale:

dynamic-charset.html
<script>
  function setFormCharset(encoding) {
    document.getElementById("dynamicForm").acceptCharset = encoding;
  }
</script>
Try It Yourself

How It Works

The setFormCharset function updates the acceptCharset DOM property on the form with id dynamicForm. Note the camelCase property name in JavaScript versus the hyphenated HTML attribute.

Example — Multiple Encodings

List more than one accepted encoding when legacy server support is required:

multiple-charsets.html
<form action="/submit" method="post" accept-charset="UTF-8 ISO-8859-1">
  <textarea name="message"></textarea>
  <input type="submit" value="Submit">
</form>
Try It Yourself

How It Works

A space-separated list tells the server which encodings the form may use. For new projects, prefer a single UTF-8 value everywhere.

♿ Accessibility

  • UTF-8 preserves user input — Correct encoding ensures screen reader users and sighted users see the same characters they typed.
  • Match document and form encoding — Avoid mojibake (garbled characters) by keeping meta charset and accept-charset aligned.
  • Label all fields — Encoding does not replace accessible labels and error messages.
  • Report encoding errors clearly — If the server rejects input, explain the issue in plain language.

🧠 How accept-charset Works

1

Author sets accept-charset

Declare UTF-8 or other encodings on the form element.

Markup
2

User submits the form

Field values are encoded using the specified charset before sending.

Submit
3

Server decodes the data

The backend interprets bytes using the accepted encoding list.

Server
=

Correct international text

Accented and non-Latin characters arrive intact on the server.

Browser Support

The accept-charset attribute is supported in all modern browsers. HTML5 documents default to UTF-8 when the attribute is omitted.

HTML5 · Fully supported

Universal form encoding support

All major browsers honor accept-charset on form submission.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer IE 9+ supported
Full support
Opera Fully supported
Full support
accept-charset attribute 99% supported

Bottom line: Use accept-charset="UTF-8" on forms; align with your page charset and server settings.

💡 Best Practices

✅ Do

  • Set accept-charset="UTF-8" on forms handling international text
  • Keep document charset, form charset, and database encoding consistent
  • Use UTF-8 for all new projects
  • Set the HTTP response charset on the server as well
  • Use acceptCharset in JavaScript when locale changes dynamically

❌ Don’t

  • Mix UTF-8 pages with legacy ISO-8859-1 form encoding without reason
  • Confuse accept-charset with enctype
  • Assume the server ignores charset if the attribute is omitted
  • Use Shift_JIS or ISO-8859-1 on new multilingual sites
  • Forget to configure server-side decoding to match

Conclusion

The accept-charset attribute is a crucial aspect of HTML forms, influencing how the server interprets and processes submitted data. By understanding and using this attribute effectively, developers can ensure seamless communication between the client and server while handling diverse character sets.

For modern websites, declare UTF-8 on your pages and forms, and verify your server and database use the same encoding end to end.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about accept-charset

Bookmark these before your next internationalized form.

5
Core concepts
🌐 02

Use UTF-8

Modern default.

Values
📄 03

vs meta charset

Submit vs document.

Comparison
⚙️ 04

acceptCharset

JavaScript property.

Dynamic
📝 05

Stay Consistent

Page, form, server.

Best Practice

❓ Frequently Asked Questions

It lists character encodings the server may use when decoding submitted form field values.
The <form> element. Set it on the form, not on individual inputs.
meta charset decodes the HTML file. accept-charset encodes form data on submit.
UTF-8 for virtually all modern websites. It supports every language and matches HTML5 defaults.
Use formElement.acceptCharset = "UTF-8" (camelCase, no hyphen).
Yes in all modern browsers. When omitted, the document encoding (usually UTF-8) is used.

Handle international form data correctly

Practice the accept-charset attribute with UTF-8 and dynamic encoding in the Try It editor.

Try UTF-8 form example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful