HTML and CSS Reference
In-Depth Information
Take a look at the following code fragment:
Input
<p> Please enter your username <form><input /> and password
<input /></form> to log in. </p>
You might think that your entire form would appear on a single line based on the preced-
ing markup. As shown in Figure 11.3, the opening and closing <form> tags act like open-
ing and closing paragraph tags.
.
Output
FIGURE 11.3
A line break
inserted by an
opening <form>
tag.
The two most commonly used attributes of the <form> tag are action and method . Both
of these attributes are optional. The following example shows how the <form> tag is typi-
cally used:
<form action=“someaction” method=“get or post”>
content, form controls, and other HTML elements
</form>
action specifies the URL to which the form is submitted. Again, remember that for the
form to be submitted successfully, the script must be in the exact location you specify
and must work properly.
If you leave out the action attribute, the form is submitted to the current URL. In other
words, if the form appears on the page http://www.example.com/form.html and you leave
off the action attribute, the form will be submitted to that URL by default. This proba-
bly doesn't seem very useful, but it is if your form is generated by a program instead of
residing in an HTML file. In that case, the form is submitted back to that program for
processing. One advantage of doing so is that if you move the program on the server, you
don't have to edit the HTML to point the form at the new location.
 
 
Search WWH ::




Custom Search