The HTML Form Element
The HTML Form Element
Form elements are probably one of the most important aspects of HTML that we come across when browsing the web. It allows communication between a client (more commonly known as the web browser) and a web server. Many of us have probably used forms at one time or another, such as when purchasing a book over the Internet, filling out product surveys or for web based email..
What is the Form Element?
It's the section of the HTML document that may contain normal content, some markup, controls (or html element such as checkboxes, radio buttons, text fields, etc.) and labels on those controls.
A typical Form element may contain a variety of controls, and one or many controls on a given form.
A form element must have a start tag and an end tag, meaning all the controls will be between the form's open and close tags.
Note: All of the controls that make up a full functional form can also appear outside of the form as well, but they function differently in either place.
Some Important Attributes
action : There are a number of attributes that are used in form elements, however a form element must always contain an action attribute. The action attribute points to a form processing application or mechanism (mostly a server side application). Action attribute values should be in the following format:
protocol : resource
A list of some valid protocols that can be used in action attributes are as follows:
ftp File Transfer protocol http Hypertext Transfer Protocol gopher The Gopher protocol mailto Electronic mail address news USENET news nntp USENET news using NNTP access telnet Reference to interactive sessions wais Wide Area Information Servers file Host-specific file names prospero Prospero Directory Service
enctype : Default value for enctype attribute is:
in the above enctype settings the form data is restricted to ASCII codes.
Another important enctype is:
The application/x-www-form-urlencoded is not suitable to send large quantities of data that may contain binary data or non-ascii characters. In situations where you are uploading files and/or other binary data, multipart/form-data content type should be used. Another important enctype that you might have used or will use in the future is text/plain. This content type value is used when you're submitting your form data using the mailto: protocol in the action attributes value. You might find that some people do not approve this usage, (but in my opinion, its perfectly valid enctype that can be used with a perfectly valid mailto protocol).
The only problem you that might encounter with the mailto protocol is that its implementation within the browser community is not as universal as one might think, hence problems may be experienced in different browsers when using the combination of action="mailto:...." and enctype="text/plain" (works as intended in IE6 and NS6+).
One more important configuration issue is that you must have an email client installed on your local system to use the above. i.e. MS Outlook or Netscape mail client.
Created: June 2, 2003
Revised: October 16, 2003