Open In App

What is formenctype Attribute in HTML Form ?

The HTML formenctype attribute is used to specify the type of encoding to be used when submitting the form. It defines how the form data should be encoded when it is sent to the server. 

It works with the input type submitand input type image“. 



The formenctype attribute is used when there are multiple submit buttons inside the form. It is used to override the feature of the enctype attribute of the <form> element.

Syntax:



<element_name formenctype=”application/x-www-form-urlencoded/multipart/form-data/text/plain”>

Basically, there are ways to be used to encode the form data.

Example: in this example, we are using formenctype attribute.




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h2 style="color:green">
            GeeksforGeeks
        </h2>
        <p>
            <b>
                What is formenctype attribute in HTML form?
            </b>
        </p>
        <form action="#">
            <label>First Name:<input type="text"></label>
            <br>
 
            <label>last Name:<input type="text"></label>
            <br>
 
            <label>Address:<input type="text"></label>
            <br><br>
 
            <input type="submit"
                   value="Submit with default encoding type">
            <button type="submit"
                    formenctype="multipart/form-data">
                Submit as multipart form-data
            </button>
        </form>
    </center>
</body>
 
</html>

Output:


Article Tags :