HTML enctype Attribute Last Updated : 28 Aug, 2024 Comments Improve Suggest changes Like Article Like Report HTML enctype Attribute specifies that data will be present in the form and should be encoded when submitting to the server. This type of attribute can be used only if method = "POST".Syntax <form enctype = "value">Attribute ValuesThis attribute contains three values which are listed below:Attribute ValuesDescriptionsapplication/x-www-form-urlencodedIt 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-dataThis value does not encode any character.text/plainThis value convert spaces into + symbols but special characters are not converted.Supported TagThe enctype attribute is associated with <form> element only. Example: In this example we demonstrates the enctype="multipart/form-data" attribute, used for file uploads. It includes fields for first name, last name, and address, and a submit button. html <!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 BrowsersThe browser supported by enctype Attribute are listed below: Google ChromeEdge FirefoxOperaSafariHTML enctype Attribute - FAQsWhen should you use enctype="multipart/form-data"?Use enctype="multipart/form-data" when your form includes file uploads (e.g., using <input type="file">). This encoding type is necessary for the server to properly handle the binary data of files.What is the default value of the enctype attribute?The default value of the enctype attribute is application/x-www-form-urlencoded. This is used when the enctype attribute is not explicitly specified.How does the enctype attribute affect form submission?The enctype attribute affects how the browser encodes the form data and how it is sent to the server. The server must be configured to handle the specified encoding type to correctly process the data.How does the enctype attribute impact file uploads?For file uploads to work correctly, the form's enctype attribute must be set to multipart/form-data. This ensures that the binary file data is sent to the server in a format it can handle.Is the enctype attribute required for all forms?The enctype attribute is not required for all forms. It is optional, but it is necessary to use it with the correct value (multipart/form-data) when dealing with file uploads or other types of data that require special encoding. Comment More infoAdvertise with us Next Article HTML enctype Attribute M manaschhabra2 Follow Improve Article Tags : Web Technologies HTML HTML-Attributes Similar Reads HTML accept Attribute HTML accept Attribute specifies the type of file that the server accepts. This attribute can be used with <input> element only. This attribute is not used for validation tools because file uploads should be validated on the Server.Syntax:<input accept = "file_extension"> Note: This attri 3 min read HTML accept-charset Attribute The accept-charset attribute is used to define the character encoding and is used for form submission. The default value of the accept-charset attribute is "UNKNOWN" string which indicates the encoding equals to the encoding of the document containing the <form> element. Syntax:<form accept 2 min read HTML accesskey Attribute The HTML accesskey attribute defines a keyboard shortcut to activate or focus an element.It assigns a keyboard key combination to trigger an element (like a link or button).Browser support and specific key combinations vary (e.g., Alt + key on Windows, Ctrl + key on macOS).Use it sparingly and provi 3 min read HTML action Attribute The HTML action attribute is used to specify where the form data should be sent on submission. It allows the browser to send the data to the specified location, enabling server-side scripts to process the data and generate a response.Note: It can be used in the <form> element. Syntax:<form 3 min read HTML align Attribute In HTML, the align attribute is used to control the alignment of elements on a webpage. Whether it's for text, images, or tables, the align attribute helps to position content in relation to its surrounding elements.Syntax<element_name align="left | right | center | justify">Attribute ValuesAt 4 min read HTML alt attribute The alt attribute in HTML provides alternative text for images, aiding accessibility and providing context for screen readers.Syntax:<img src=" " alt=" " >HTML<html> <body> <h1>GeeksforGeeks Logo</h1> <img src="https://media.geeksforgeeks.org/wp-content/uploads/20190 3 min read HTML async Attribute The HTML <script> async attribute is used to load and execute external scripts without blocking the rest of the page from loading. This speeds up page load times. It only works with external scripts (when the src attribute is present).Syntax:<script src="path-to-script.js" async></scr 3 min read HTML autocomplete Attribute The HTML autocomplete Attribute is used to specify whether the input field autocompleted would be on or off. When the autocomplete attribute is set to on the browser will automatically complete the values based on what the user entered before. It works with input fields such as text, search, URL, em 3 min read HTML autoplay Attribute The HTML autoplay Attribute, a boolean attribute, enables audio or video elements to start playing automatically when the page loads, providing seamless playback without interruption.Syntax: <element autoplay> Supported ElementsIt can be used with <audio> and <video> elements. Elem 2 min read HTML autofocus Attribute The HTML autofocus attribute is a powerful tool that enhances user experience by automatically setting the focus to a specific element when a webpage loads. Syntax<input type="text" autofocus> Note: This attribute is boolean, meaning it can either be present or absent.Supported TagsElementPurp 2 min read Like