The <form> Tag

The form tag in XHTML is used to create… well… forms on a webpage for user input.

Within the form tag the most common content are:

  • <input>
    • Used to specify an input field
  • <textarea>
    • Used to create a text input control
  • <button>
    • Used to created an intractable button
  • <select>
    • Used to create a drop down list
  • <option>
    • Used to create an option inside of a select list
  • <optgroup>
    • Used to group options in a select list
  • <fieldset>
    • Used to group elements in a form with a border
  • <label>
    • Used to create a label for an input element

There are three significant attributes within the form tag called method, action and enctype.

Method is used to specify how the data gathered from the form is sent, through either get or post.

  • Get sends the data from the form appended in the URL

    • URL is limited to 3000 characters
    • The data received is visible (bad for sensitive data)
    • Is useful if the user wants to save a page using the results of a form
  • Put sends the data from the form appended inside the HTTP request
    • Size is not limited
    • The data received is hidden
    • Pages with form results cannot be saved

Action is used to specify where to send the data collected from the form, with the specification being a URL.

Enctype is used to specify how the data collected from the form should be encoded, through either application/x-www-form-urlencoded, multipart/form-data or text/plain.

  • Can only be used with put method
  • Application/x-www-form-urlencoded encodes all characters before sending by changing spaces to + and special characters into ASCII and HEX values
  • Multipart/form-data does not encode characters (for forms that have a  file upload control)
  • Text/plain only converts spaces to +

http://www.w3schools.com/tags/tag_form.asp

Advertisements
Comments
One Response to “The <form> Tag”
  1. gregc132 says:

    Thanks for the post and reference

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: