HTML Tag Reference - HTML tag <form>








This <form> element creates a form and submits to send information to a server for further processing.

Browser compatibility

<form> Yes Yes Yes Yes Yes

What's new in HTML5

HTML5 has added two new attributes: autocomplete and novalidate, and removed the accept attribute.

Attribute

accept
Value:file_type
Not supported in HTML5. Creates a comma-separated list of file types that the server accepts
accept-charset
Value:character_set
character encodings for the form submission
action
Set the URL to send the form-data when submitting a form
autocomplete
Value:on|off
Set autocomplete on or off
enctype
Value:application/x-www-form-urlencoded
multipart/form-data
text/plain
Form-data encoding for method="post"
method
Value:get|post
Set the HTTP method when sending form-data
name
the name of a form
novalidate
Value:novalidate
Set not to validate the form
target
Value:_blank|_self|_parent|_top
where to display the response

Global Attributes

The <form> tag supports the Global Attributes in HTML.





Event Attributes

The <form> tag supports the Event Attributes in HTML.

Default CSS Settings

form {
    display: block;
    margin-top: 0em;
}

Example

A demo showing how to use <form> tag.

<html>
<body>
   <form name="form2" method="post" action="your.htm">
      <input type="text" 
             name="textfield2" 
             value="This is a text field" 
             size="30"/>
      <br/> 
      <input type="checkbox" 
             name="checkbox2" 
             value="checkbox"/>A checkbox.
      <br/> 
      <input type="radio" 
             name="radiobutton" 
             value="radiobutton"/>A radio button.<br/>
      <input type="button" 
             name="myButton2" 
             value="Submit"/>A submit button.
   </form><!--from w  ww. j a v  a 2  s.  c o  m-->
</body>
</html>

Click to view the demo