html tutorial - form Attribute in HTML - html5 - html code - html form



 form attribute in html

Learn html - html tutorial - form attribute in html- html examples - html programs

  • The form attribute specifies the element belongs to one or more forms.
  • The owner of the element will indicate the form.

Syntax for form attribute in HTML:

<element form="form_id">

Differences between HTML 4.01 and HTML5 for form attribute:

HTML 4.01

  • The form attribute does not support in HTML4.

HTML 5

  • HTML5 support form attribute.

Applies To:

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

Attribute Values:

Value Description
form_id
  • Defines the form element belongs to the some of the tags.
  • The value of this attribute must be the id attribute of a <form> element in the same document.
  • Sample Coding for form Attribute in HTML:

    Tryit<!DOCTYPE html>
    <html>
            <head>
            <title>Wikitechy form attribute</title>
            </head>
     <body>
            <form action="form.html" id="form_1">
            Firstname:<input type="text" name="fname"> <br>
            <input type="submit" value="Submit">
            </form>
            <p>Lastname:<input type="text" name="lname" form="form_1">
            </p>
    </body>
    </html>

    Code Explanation for form Attribute in HTML:

     form Attribute Code Explanation

    1. The <form> tag is used to define a form with input elements.
    2. Id attribute is used to define the <form> tag id as “form_1”.
    3. The form attribute is used to append the <inputt> tag to the form which has the id attribute as “form_1”.
    4. The type=”submit”is used to submit the form-data When the user click the submit button.

    Output for form Attribute in HTML:

    form Attribute Tag Output

    1. The Firstname text box is used to type a person’s first name.
    2. The submit button, is used to submit the person’s name to the form.
    3. The Lastname text box is used to type a person’s last name.
    4. form1 Attribute Tag Output

    5. When the user c <form> tag but that will be also submitted because of “form” attribute.

    Browser Support for form Attribute in HTML:

    Elements
    button 10 No 4 5.1 9.5
    fieldset No No No No No
    input 9 No 4 5.1 10.6
    keygen Yes No Yes 6 Yes
    label Yes Yes Yes Yes Yes
    meter No No No No No
    object No No No No No
    output Yes Yes Yes Yes Yes
    select Yes No Yes Yes Yes
    textarea Yes No Yes Yes Yes

    Related Searches to form Attribute in html