Content · Web Development · HTML

HTML enctype Attribute: Reference and Examples

A clear, practical attribute reference to enctype. Learn when to use it, see working HTML, and avoid common mistakes.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

The enctype attribute is a small instruction attached to an HTML element. Its job is to choose form request body format. It is easier to remember when you can see it in a real piece of markup.

What enctype is used for


Choose form request body format. The attribute appears inside an element’s opening tag. Depending on its definition, it may take a specific string, a number, an enumerated keyword, or be a boolean attribute.

The example below uses it in a form context. Other elements may support it too, or may give the same attribute a different meaning.

Example you can try


<form action="/contact" method="post" enctype="multipart/form-data">
    <label for="message-text">Message</label>
    <input id="message-text" name="message" type="text">
    <label for="attachment">Attachment</label>
    <input id="attachment" name="attachment" type="file">
    <button type="submit">Send</button>
</form>

How the example works


Look for enctype in the snippet. Here the example shows the value multipart/form-data. This is a concrete input the browser can interpret; it is not just text shown to the reader.

The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.

Values and important behavior


Use application/x-www-form-urlencoded for ordinary form data and multipart/form-data for file uploads. text/plain is mainly for debugging.

This detail matters most when the page receives user input, navigates to another document, or loads an external resource. In those cases, check the browser behavior and any server-side requirements separately.

Small practice task


Copy the code and change enctype to another sensible value, or remove it entirely if it is optional. Test the difference in the browser and inspect any submitted value or network request.

Common Beginner Mistakes


  • The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.
  • Using enctype on an element that does not support it.
  • Believing that an HTML hint or client-side check replaces real server validation or a security policy.

Key Takeaways


  • enctype is used to choose form request body format.
  • The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.
  • Choose valid values and test the result instead of guessing what the browser will do.
Share this resourceSend this page to someone who may find it useful.