HTML Page Structure

HTML Elements
HTML Attributes


HTML Form Tag

If you want to make your website interactive or collect user's responses and inputs, you need to use <form> tag. HTML form tag <form> and </form> is used to create a form on the web page.

JavaScript, CGI or PHP is used to write scripts for making form interactive in order to collect inputs from the users, maintain user inputs data received through your web page.

You can place the form tag anywhere inside the Body of an HTML document. Text boxes, Radio buttons, Check boxes, Drop down list and Other input fields are used to create a form.

Basic attributes to a form are Action, Method and Enctype. Action attribute refers to the URL to which the form submission is sent which is usually be a server side script written in PHP or Pearl. Method attribute referes to the method of sending data to the Action URL. Method will be either "get" or "post". "Get" is suited for small forms and it is a default method whereas "Post" is used for comparatively larger forms. Enctype attribute refers to the format of the data submitted to the server.

Syntax

<form action="action_form.php" method="get" enctype="text/plain">
	form-associated elements will come here...
</form>

Example

<!DOCTYPE html>
<html>
<head>
<title>My HTML Form Example</title>
</head>
<body>
<form action="mailto:your email" method="get" enctype="text/plain">
      <p>
        Name: <input type="text" id="name" size="25"/>
     </p>
      <p>
        Please rate hotel service from 1 to 3 (1 = worst and 3= excellent): <br />
       <select id="service rating"><br />
          <option>1</option>
          <option>2</option>
          <option selected>3</option>
       </select>
      </p>
     </form>
</body>
</html>

This will produce following result

Name:

Please rate hotel service from 1 to 3 (1 = worst and 3= excellent):