-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics
HTML Input Form Attributes are special attributes used on <input>
elements to associate them with a form, or define how they behave when the form is submitted.
These attributes provide flexibility to manage form data, especially when inputs are located outside the <form>
tag.
Attribute | Description |
---|---|
form |
Links an <input> to a specific <form> by its id |
formaction |
Overrides the form's action URL when a submit button is clicked |
formenctype |
Overrides the form's enctype attribute (usually for file uploads) |
formmethod |
Overrides the form’s method attribute (get or post ) |
formnovalidate |
Prevents validation when that button is clicked |
formtarget |
Overrides the form’s target attribute (like _blank , _self , etc.) |
form
Attribute Outside <form>
<form id="userForm" action="/submit" method="post">
<input type="text" name="name">
</form>
<!-- This input is outside the form but still linked -->
<input type="email" name="email" form="userForm">
formaction
and formmethod
<form action="/register" method="post">
<input type="text" name="username">
<button type="submit" formaction="/save-user" formmethod="get">Submit via GET</button>
</form>
formenctype
<form action="/upload" method="post">
<input type="file" name="file">
<input type="submit" formenctype="multipart/form-data">
</form>
Q1. Use the form
attribute to link an input that is outside the <form>
tag.
Q2. Create a form with a submit button that overrides the main form’s action
using formaction
.
Q3. Use formmethod="get"
to submit the form using GET only from one button.
Q4. Add formenctype="multipart/form-data"
to a file upload input.
Q5. Prevent validation using formnovalidate
on a submit button.
Q6. Use formtarget="_blank"
to open the form response in a new tab.
Q7. Combine formaction
and formtarget
in the same button.
Q8. Create two inputs outside the form and link both using form="form_id"
.
Q9. Create a form with two buttons: one for GET and one for POST using formmethod
.
Q10. Build a form that accepts file and submits using customized form attributes on the submit button.
HTML5 Basics
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Styling and Design
HTML Links and Media
HTML Layout and Structure
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
HTML Graphics
HTML APIs
HTML Advanced Topics