Working with Elements Outside the Form - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:form

Introduction

You can associate elements with forms anywhere in the document.

To associate an element with a form, set the form attribute to the id value of the form.

Using the form Attribute

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form id="voteform" method="post" action="http://example.com/form"> 
         <p> 
            <label for="fave">
               Fruit: <!--  w w w  .j  ava2  s . co m-->
               <input autofocus id="fave" name="fave">
            </label> 
         </p> 
      </form> 
      <p> 
         <label for="name">
            Name: 
            <input form="voteform" id="name" name="name"> 
         </label> 
      </p> 
      <button form="voteform" type="submit">Submit Vote</button> 
      <button form="voteform" type="reset">Reset</button>  
   </body>
</html>

Related Tutorials