Horje
What is HTML form Attribute

Definition and Usage

The form attribute specifies the form the element belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Applies to

The form attribute can be used on the following elements:

Elements Attribute
<button> form
<fieldset> form
<input> form
<label> form
<meter> form
<object> form
<output> form
<select> form
<textarea> form

Browser Support

The form attribute has the following browser support for each element:


How to add A button located outside a form (but still a part of the form)

Button Example.
index.html
Example: HTML
 <form action="/action_page.php" method="get" id="form1">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
</form>

<button type="submit" form="form1" value="Submit">Submit</button> 

Output should be:

How to add A button located outside a form (but still a part of the form)

How to add A <fieldset> element located outside a form (but still a part of the form)

Fieldset Example.

index.html
Example: HTML
 <form action="/action_page.php" method="get" id="form1">
  What is your favorite color? <input type="text" name="fav_color"><br>
  <input type="submit">
</form>

<fieldset form="form1">
  Name: <input type="text" name="username"><br>
  Email: <input type="text" name="usermail"><br>
</fieldset> 

Output should be:

How to add A <fieldset> element located outside a form (but still a part of the form)

How to add An input field located outside the HTML form (but still a part of the form)

Input Example.

index.html
Example: HTML
 <form action="/action_page.php" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

Last name: <input type="text" name="lname" form="form1"> 

Output should be:

How to add An input field located outside the HTML form (but still a part of the form)

How to add A <label> element located outside a form (but still a part of the form)

Label Example.

index.html
Example: HTML
 <form action="/action_page.php" id="form1">
  <input type="radio" id="html" name="fav_language" value="HTML"><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>

<label for="html">HTML</label> 

Output should be:

How to add A <label> element located outside a form (but still a part of the form)

How to add A <meter> element located outside a form (but still a part of the form)

Meter Example.

index.html
Example: HTML
 <form action="/action_page.php" method="get" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

<meter form="form1" name="x1" min="0" low="40" high="90" max="100" value="95"></meter> 

Output should be:

How to add A <meter> element located outside a form (but still a part of the form)

How to add An <object> element located outside a form (but still a part of the form)

Object Example.

index.html
Example: HTML
 <form action="/action_page.php" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

<object data="helloworld.swf" height="400" width="400" form="form1" name="obj1"></object> 

Output should be:

How to add An <object> element located outside a form (but still a part of the form)

How to add An <output> element located outside a form (but still a part of the form)

Output Example.

index.html
Example: HTML
 <form action="/action_page.php" id="numform"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" id="a" name="a" value="50">100
+<input type="number" id="b" name="b" value="50">
<br><br>
<input type="submit">
</form>

<output form="numform" name="x" for="a b"></output> 

Output should be:

How to add An <output> element located outside a form (but still a part of the form)

How to add A drop-down list located outside a form (but still a part of the form)

Select Example.

index.html
Example: HTML
 <form action="/action_page.php" id="carform">
  Firstname:<input type="text" name="fname">
  <input type="submit">
</form>

<select name="carlist" form="carform">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add A drop-down list located outside a form (but still a part of the form)

How to add A text area located outside a form (but still a part of the form)

Textarea Example.

index.html
Example: HTML
 <form action="/action_page.php" id="usrform">
  Name: <input type="text" name="usrname">
  <input type="submit">
</form>

<textarea name="comment" form="usrform">Enter text here...</textarea> 

Output should be:

How to add A text area located outside a form (but still a part of the form)




html form attribute

Related Articles
How to add HTML accept Attribute HTML Input HTML Attribute
How to add HTML accept-charset Attribute HTML Attribute
What is HTML accesskey Attribute HTML Attribute
What is HTML action Attribute HTML Attribute
What is HTML alt Attribute HTML Attribute
What is HTML async Attribute HTML Attribute
What is HTML autocomplete Attribute in HTML HTML Attribute
What is HTML autofocus Attribute HTML Attribute
What is HTML autoplay Attribute HTML Attribute
What is HTML charset Attribute HTML Attribute
What is HTML checked Attribute HTML Attribute
What is HTML cite Attribute HTML Attribute
What is HTML class Attribute HTML Attribute
What is HTML cols Attribute HTML Attribute
What is HTML colspan Attribute HTML Attribute
What is HTML content Attribute HTML Attribute
What is HTML contenteditable Attribute HTML Attribute
What is HTML controls Attribute HTML Attribute
What is HTML coords Attribute HTML Attribute
What is HTML data Attribute HTML Attribute
What is HTML data-* Attribute HTML Attribute
What is HTML datetime Attribute HTML Attribute
What is HTML controls Attribute HTML Attribute
What is HTML default Attribute HTML Attribute
What is HTML defer Attribute HTML Attribute
What is HTML dir Attribute HTML Attribute
What is HTML dirname Attribute HTML Attribute
What is HTML disabled Attribute HTML Attribute
What is HTML download Attribute HTML Attribute
What is HTML draggable Attribute HTML Attribute
What is HTML enctype Attribute HTML Attribute
What is HTML enterkeyhint Attribute HTML Attribute
What is HTML for Attribute HTML Attribute
What is HTML form Attribute HTML Attribute
What is HTML formaction Attribute HTML Attribute
What is HTML headers Attribute HTML Attribute
What is HTML height Attribute HTML Attribute
What is HTML hidden Attribute HTML Attribute
What is HTML high Attribute HTML Attribute
What is HTML href Attribute HTML Attribute
What is HTML hreflang Attribute HTML Attribute
What is HTML http-equiv Attribute HTML Attribute
What is HTML id Attribute HTML Attribute
What is HTML inert Attribute HTML Attribute
What is HTML inputmode Attribute HTML Attribute
What is HTML ismap Attribute HTML Attribute
What is HTML kind Attribute HTML Attribute
What is HTML label Attribute HTML Attribute
What is HTML lang Attribute HTML Attribute
What is HTML list Attribute HTML Attribute
What is HTML loop Attribute HTML Attribute
What is HTML low Attribute HTML Attribute
What is HTML max Attribute HTML Attribute
What is HTML maxlength Attribute HTML Attribute
What is HTML media Attribute HTML Attribute
What is HTML method Attribute HTML Attribute
What is HTML min Attribute HTML Attribute
What is HTML multiple Attribute HTML Attribute
What is HTML muted Attribute HTML Attribute
What is HTML name Attribute HTML Attribute
What is HTML novalidate Attribute HTML Attribute
What is HTML onabort Attribute HTML Attribute
What is HTML onafterprint Attribute HTML Attribute
What is HTML onbeforeprint Attribute HTML Attribute
What is HTML onbeforeunload Attribute HTML Attribute
What is HTML onblur Attribute HTML Attribute
What is HTML oncanplay Attribute HTML Attribute
What is HTML oncanplaythrough Attribute HTML Attribute
What is HTML onchange Attribute HTML Attribute
What is HTML onclick Attribute HTML Attribute

Single Articles
How to add A button located outside a form (but still a part of the form)HTML Attribute
How to add A <fieldset> element located outside a form (but still a part of the form)HTML Attribute
How to add An input field located outside the HTML form (but still a part of the form)HTML Attribute
How to add A <label> element located outside a form (but still a part of the form)HTML Attribute
How to add A <meter> element located outside a form (but still a part of the form)HTML Attribute
How to add An <object> element located outside a form (but still a part of the form)HTML Attribute
How to add An <output> element located outside a form (but still a part of the form)HTML Attribute
How to add A drop-down list located outside a form (but still a part of the form)HTML Attribute
How to add A text area located outside a form (but still a part of the form)HTML Attribute

Read Full:
HTML Attribute
Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded:
1 week ago
Uploaded by:
Admin
Views:
56


Reffered: https://www.w3schools.com/tags/att_form.asp

Share on: