HTML and CSS Reference
In-Depth Information
with a search input, but you can also use it with any of the textual input types, including URL, e-mail, and
telephone controls, as well as the textarea element covered later in this chapter.
Figure 8-3 shows the search input showing off its placeholder text. This image is taken from Safari for OS
X, which also styles search inputs with rounded corners by default. Older browsers that don't support
placeholder will simply ignore the attribute and display a plain, empty field. Because some browsers
can't display it, always think of placeholder text as an optional hint, and you should display any really vital
information some other way (in a label , perhaps).
Figure 8-3 . How the search field appears in Safari, including placeholder text. Safari styles search inputs with rounded
ends by default, in keeping with Apple's general style for search boxes on OS X, but other browsers will differ.
Some browsers already recognize search inputs and will display a dropdown of recent search terms as
you type, matching the text you've entered and narrowing the suggestions as you enter more letters. Safari
and Chrome—and possibly other browsers in the near future—also add a small clearing button at the end
of search fields when a user enters a value (as in Figure 8-4). This makes it easy to empty the control with
a single click, clearing the field for the next search. Not every browser does this; it's just an extra touch
WebKit adds.
Figure 8-4. Safari adds a small clearing button to search fields, and recalls previous searches in a dropdown while also
offering to auto-complete the text as you type.
input type="password"
This control is similar to a text field; it's a single-line field and will usually appear as a rectangular box with
a white background and an inset border. But unlike a regular text field, a password field obscures the
entered text, usually as a series of solid dots or asterisks (*). This offers a bit of added security and
privacy, preventing someone from peering over your shoulder to sneak a peek at your secret password
when you're logging into a secure system. But this is very light security, protecting your password from a
casual glance only. A properly secured form should be encrypted when it's submitted to the server; don't
count on just visually obscuring passwords to keep a determined crook at bay.
Search WWH ::

Custom Search