HTML and CSS Reference
In-Depth Information
By contrast, the post method sends the data set directly to the form handler application (not in a visible
URL query string) for processing at the server. The post method sends data to the server where it can be
saved for use in the future, for example, submitting a comment or uploading a video. It can also be useful
when a URL with a visible query string isn't desirable for reasons of security and privacy, for instance
when you submit your password to log into a secure website.
HTTP stands for HyperText Transfer Protocol, the set of program rules used for
transferring electronic data over the Web. The two most basic methods of HTTP are
“get” to send data from a server to a client and “post” to send data from a client to a
server. Whenever you download something from a web server, be it an HTML
document, a cascading style sheet, a video, an image, or anything else, your browser
sends a request to “get” that file. Many forms use the opposite “post” method, sending
data from your browser to the server. Other HTTP methods exist, but “get” and “post”
are the only ones used with forms in HTML.
Listing 8-1 shows the markup for a simple form, including the action and method attributes in the opening
<form> tag. This example contains two input elements (an e-mail field and a submit button) and a text
label wrapped in a label element. You'll learn more about all of these elements in this chapter.
Listing 8-1 . A simple form with an e-mail field and a submit button
<form method="post" action="/apps/">
<p><label for="email">Enter your e-mail address to
subscribe to our newsletter.</label></p>
<p><input type="email" name="email" id="email" required>
<input type="submit" value="Subscribe"></p>
Figure 8-1 shows how this form is rendered in a web browser with default styling, Firefox for Mac OS X in
this case. Some form controls will look different in different browsers and on different operating systems,
but in the end they all send their data the same way.
Figure 8-1. The same simple form as it appears in Firefox for Mac OS X
The label element is extremely important in forms. It provides a text label for a form
control that assistive technologies can read to make the form more accessible and
easier to use. You'll learn about it in detail later in this chapter.
Search WWH ::

Custom Search