freecourses.digital
Lesson progress: 0 of 3 activities done
All lessons in HTML Basics for Beginners Lesson 7.2 of 34

Module 10: Practice Project and Validation

  1. 10.1Build a simple HTML website

Text fields, email fields, and text areas

Covered here

  • The <input> element and its type
  • Email, tel, number, and date inputs
  • The <textarea> for longer messages
  • placeholder and autocomplete

Short answer

Most form fields are <input> elements, and the type attribute decides what kind. type="email" checks for an @ sign and shows an email keyboard on phones. type="tel" shows a number pad. Use <textarea> for longer messages. Add autocomplete so browsers can fill in details for the visitor.

Common input types

typeUsePhone keyboard
textNames, short answersNormal
emailEmail addressesHas @ and .com
telPhone numbersNumber pad
numberQuantitiesNumbers
dateBooking datesDate picker
passwordPasswordsHides characters
searchSearch boxesSearch key

Using the right type is one of the easiest ways to make forms faster on mobile.

Examples

<input type="text" name="full_name" autocomplete="name">
<input type="email" name="email" autocomplete="email">
<input type="tel" name="mobile" autocomplete="tel" placeholder="0917 123 4567">
<input type="number" name="boxes" min="1" max="20" value="1">
<input type="date" name="check_in">

The textarea element

<label for="msg">Your message</label>
<textarea id="msg" name="message" rows="5" maxlength="1000"></textarea>

Unlike input, textarea has a closing tag. Any text between the tags becomes the default value, so keep it empty. rows sets the visible height.

placeholder and autocomplete

A placeholder shows example text inside the field until the visitor types. It is a hint, not a label. It disappears when typing starts and is often low contrast.

autocomplete tells the browser what the field is, like name, email, tel, or street-address. Chrome and Safari can then fill saved details with one tap.

Try it: pick the right types

Every field is type text. Change each to the best type, add autocomplete, and make the message a textarea.

Live preview

Quick quiz

1. Which type shows a number pad on phones?
2. Which element is best for long messages?
3. Is placeholder a replacement for a label?
4. What does autocomplete="email" do?

Common mistakes

  • Everything as type text. Visitors lose the right keyboard and checks.
  • Placeholder as the only label. The hint disappears while typing.
  • Text between textarea tags. It becomes real content that may be submitted.

Your action

Tick each item when you can do it. Your progress saves on this device.

Key terms

<input>
A void element for one form field.
type attribute
Sets the kind of input.
<textarea>
A multi-line text field.
placeholder
Hint text shown before typing.
autocomplete
Tells browsers how to autofill a field.

Questions beginners ask

Should phone numbers use type number?

No. Use tel. Numbers drop leading zeros and add spinner arrows.

Does type email check if the address exists?

No. It only checks the format.

Can I limit text length?

Yes, with maxlength and minlength.

Related lessons

Need a website built or fixed while you practice? The team at Remar Digital can help.