basics of website design banner photo

HTML

HTML 5

CSS 2.1

CSS 3

Reference



HTML <form> Element.

The form element contains all the component elements of an HTML online form. Forms are a way of capturing user input whether they be personal details, user preferences or an order for goods or services. This input is entered into the form and then the information is sent, usually over the Internet, for whatever action is required in response to the information given.

The opening <form> tag has attributes which tell the client computer where and how to send the information.

  1. The action attribute contains the address to which the information in the form needs to be sent and is normally a URI.
  2. The method attribute contains the method used to send the form information to the address given in the action attribute and can have the values get or post.

Using get the form data is sent via the address bar and appears as the form action value followed by a question mark followed by the form data.
Using post the form information is sent in a message containing a list of control name and control value pairs.

<form> Attributes

  • CORE AND LANGUAGE ATTRIBUTES - class, id, title, style, dir, lang

  • MOUSE AND KEYBOARD EVENT ATTRIBUTES - onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmouseout, onmousemove, onkeydown, onkeyup, onkeypress
  • action - REQUIRED - the address to which the form data needs to be sent.
  • method - the method used to send the form data to wherever it needs to go - can have the values get or post.
  • enctype - specifies the content type to be used when the form is submitted using the post method.
  • accept-charset - specifies the character encoding set or sets of the form input that the processing address can expect.
  • accept - gives a list of content types that will be accepted by the form processing address.
  • name - gives the form element a name so it can be referred to from a style sheet or found by a script. NOTE: The id attribute should be used to name elements in preference to this attribute.
  • onsubmit - defines an event which occurs when the form is submitted.
  • onreset - defines an event that occurs when the form is reset.

HTML 4 Element List