Back to course

Lesson 22: The `<input>` Element and Basic Types (Text, Password, Email)

The HTML Masterclass: From Zero to Web Developer

22. The <input> Element and Basic Types

The <input> element is the most versatile form element, controlled by its mandatory type attribute.

22.1 General Attributes for <input>

  • name: Crucial! This is the key used by the server to identify the data when it is submitted (e.g., name="username").
  • value: The default text displayed in the input field.

22.2 Basic Input Types

1. Text Input

Used for single lines of generic text.

html

2. Password Input

Masks the input (dots or asterisks) for security.

html

3. Email Input (HTML5 Validation)

If supported by the browser, this type automatically validates that the input looks like an email address (@ and a domain).

html