Tutorialspoint.dev

HTML | enctype Attribute

This Attribute specifies that data that will be present in form should be encoded when submitting to the server. This type of attribute can be used only if method = “POST”.

Syntax:

<form enctype = "value">

Element: The enctype attribute is associated with <form> element only.

Attribute Value: This attribute contains three value which are listed below:

  • application/x-www-form-urlencoded: It is the default value. It encodes all the characters before sent to the server. It converts spaces into + symbols and special character into its hex value.
  • multipart/form-data: This value does not encode any character.
  • text/plain: This value convert spaces into + symbols but special characters are not converted.

Example:

<!DOCTYPE html>
<html>
    <head>
        <title>enctype attribute</title>
        <style>
            h1 {
                color:green;
            }
            body {
                text-align:center;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>enctype Attribute</h2>
        <form action="#" method="post" enctype="multipart/form-data">
            First name: <input type="text" name="fname"><br>
            Last name: <input type="text" name="lname"><br>
            Address: <input type="text" name="Address"><br
            <input type="submit" value="Submit">
        </form>
    </body>
</html>                    

Output:

Supported Browsers: The browser supported by enctype Attribute are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter