HTML form attribute

HTML form attribute associates input element with a specific form.

Example

<p>form attribute in the input element associates it with the form</p>
 <p> Email: <input type="email" name="cemail" form="cform"></p>

<form action="files/form.php" method="post" id="cform">
 Candidate name: <input type="text" name="cname">
 Password: <input type="password" name="pass">
  <input type="submit" name="submit">
</form>
Try </>

form attribute value

The value of form attribute is the id of the <form> element. Although 'email' is outside the form but still a part of the form because of this attribute.

Related Tags

The tags that support this attribute are as follows.

<button> tag

button element defines a button labeled by the content. form attribute is also applicable on the button element.

Example

<form action="files/formbutton.php" method="post" id="data">
 <input type="text" name="guest-name" >
</form>

<button type="submit" name="send" form="data">Send</button>

Try</>

<fieldset> tag

fieldset element encloses a form structure in a box. It also supports the form attribute.

<input> tag

input tag defines an input field where a user can enter the required information. input tag supports form attribute.

See the first example to understand.

<label> tag

label tag is used to write captions. for attribute is applicable on the label element.

<select> tag

select tag offers different options in the form of drop down list.

Example

<select name="sl" form="data"> 
  <option> Australia
  <option> Egypt
  <option> Algeria
  <option> India
</select> 

<form action="files/formselect.php" method="post" id="data">
 <input type="submit" name="select">
</form>

Try</>

<textarea> tag

textarea tag element defines multi line editable area of text.

Example

<textarea name="ta" form="data"> </textarea>
<form action="files/formtextarea.php" method="post" id="data"> 
 <input type="submit" name="send">
</form>

Try</>


Was this article helpful?

 

Email:

Message:

Get the newsletter