Specify Form Data Encoding in HTML



Use enctype attribute in HTML to set whether the form-data should be encoded while submitting to the server.

Example

You can try to run the following code to implement enctype attribute −

<!DOCTYPE html>
<html>
   <body>
      <p>Which sports do you like?</p>
      <form action = "" method = "post" enctype = "multipart/form-data">
         <input type = "checkbox" name = "vehicle" value = "football" checked> Football<br>
         <input type = "checkbox" name = "vehicle" value = "cricket" checked> Cricket<br>
         <input type = "checkbox" name = "vehicle" value = "hockey"> Hockey<br>
         <input type = "submit" value = "Submit">
      </form>
   </body>
</html>
Updated on: 2020-03-03T05:34:29+05:30

185 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements