Trusted answers to developer questions

HTML forms

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

In HTML, forms are a way of receiving input from users and are, therefore, very useful for collecting website data. Forms have a lot of relevance in modern times as they are commonly used for sign-ups, authentication, and comments.

A form can be created with the form tag.

However, the tag alone isn’t of much use. So, HTML provides a variety of attributes and elements that extend the functionality of forms.

Form input

The most useful component of a form is the input tag, which creates a text field where users can enter data. Here’s an example:

As seen in the code above, there is a type and name associated with inputs. The type defines the nature of the input (text, submit, etc), while the name allows us to access the input data for future use. You can think of the name as a variable in which the input data is stored. Other properties of input include:

  • size
  • value
  • maxlength
  • readonly

Submission button

A button can be used to submit the data in a form. This is where the name of the form will come in handy.

For more details on HTML form attributes, check out the official documentation.

RELATED TAGS

html
web
input
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?