Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

320 LESSON 12: Designing Forms


elements. That means when you start a form, a new line is inserted (unless you apply the
display: inline CSS property to the form tag).


In older versions of HTML, form controls had to be placed inside
a <form> tag and then inside a block-level element to be valid.
But HTML5 doesn’t require either of these things. Instead, you
should use the <form> tag when you need to collect a group of
form controls and submit them all to the server for processing.

NOTE

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 12.4, the opening and closing <form> tags act like open-
ing and closing paragraph tags.

Output ▼


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>

FIGURE 12.4
A line break
inserted by an
opening <form>
tag.

Free download pdf