i

Learn HTML and CSS in 10 Days

Text Fields And Text Areas

When one wants to get text input from the users, there are a couple of ways to achieve it using HTML. Text fields and Text areas are 2 of the most important ones for getting string and text-based data. This data may include a telephone number, passwords, passages of text content, and other info.

Text Fields

One of the most fundamental elements utilized to get a text from the users is the   element. This element takes the help of the 'type' attribute to describe the type of data to be taken in by the controls. One of the most popular values for the 'type' attribute is the 'text'.

In addition to the 'type' attribute, it is recommended to provide a 'name' attribute. This attribute provides a name to that input element.

The element is self-contained i.e., it does not have an ending tag. Initially, the 'type' attribute used to take two values, password and text. But with the advent of HTML5, several new values for the 'type' attribute came in.

These values were used to offer a clearer picture about the type of input. Given below is the list of HTML5 new input ‘type’ values.

  • color

  • email

  • range

  • time

  • date

  • month

  • search

  • url

  • datetime

  • number

  • tel

  • week

Textarea

is another element that helps in getting the data from the user. This element accepts a larger amount of data than the input element. This element also consists of a start as well as an end tag that can bind plain text. As this element takes in only one category of value, the 'type' attribute is absent while one can use the 'name' attribute.