HTML and CSS Reference
To display text in the text control before the user enters any information, use the value
attribute. If the user is updating data that already exists, you can specify the current or
default value using value , or you can prompt the user with a value:
<input type=“text” name=“petname” size=“15” maxlength=“15” value=“Enter Pet
In this case, Enter Pet Name appears in the field when the form is rendered in the web
browser. It remains there until the user modifies it.
When you're using the value attribute, using a value that's larger
than the size of the text control can confuse the user because the
text will appear to be cut off. Try to use only enough information to
make your point. Ensure that any value is less than or equal to
the number of characters you specified in size .
Creating Password Controls
The password and text field types are identical in every way except that the data entered
in a password field is masked so that someone looking over the shoulder of the person
entering information can't see the value that was typed into the field.
You don't have to limit your use of the password control to just
passwords. You can use it for any sensitive material that you feel
needs to be hidden when the user enters it into the form.
To create a password control, create an input element with the type set to password . To
limit the size of the password control and the maximum number of characters a user can
enter, you can use the size and maxlength attributes just as you would in a text control.
Here's an example:
<label for=”userpassword”> Enter your password </label> <input type=“password”
size=“8” maxlength=“8” />
Figure 11.6 shows a password control.