A webform, web form or HTML form on a
web page allows a user to enter data that is sent to a
server
Server may refer to:
Computing
*Server (computing), a computer program or a device that provides functionality for other programs or devices, called clients
Role
* Waiting staff, those who work at a restaurant or a bar attending customers and su ...
for processing. Forms can resemble
paper
Paper is a thin sheet material produced by mechanically or chemically processing cellulose fibres derived from wood, rags, grasses or other vegetable sources in water, draining the water through fine mesh leaving the fibre evenly distributed ...
or
database
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases sp ...
forms because web users fill out the forms using checkboxes,
radio buttons
A radio button or option button is a graphical control element that allows the user to choose only one of a predefined set of mutually exclusive options. The singular property of a radio button makes it distinct from checkboxes, where the user ...
, or
text fields
type=search
placeholder=An example text box, which can be used to search the English Wikipedia.
A text box (input box), text field or text entry box is a control element of a graphical user interface, that should enable the user to input ...
. For example, forms can be used to enter
shipping
Freight transport, also referred as ''Freight Forwarding'', is the physical process of transporting Commodity, commodities and merchandise goods and cargo. The term shipping originally referred to transport by sea but in American English, it h ...
or
credit card
A credit card is a payment card issued to users (cardholders) to enable the cardholder to pay a merchant for goods and services based on the cardholder's accrued debt (i.e., promise to the card issuer to pay them for the amounts plus the o ...
data to order a product, or can be used to retrieve search results from a
search engine
A search engine is a software system designed to carry out web searches. They search the World Wide Web in a systematic way for particular information specified in a textual web search query. The search results are generally presented in a ...
.
Description
Forms are enclosed in the
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
<form>
element. This element specifies the
communication endpoint
A communication endpoint is a type of communication network node. It is an interface exposed by a communicating party or by a communication channel. An example of the latter type of a communication endpoint is a publish-subscribe topic or a grou ...
the data entered into the form should be submitted to, and the
method
Method ( grc, μέθοδος, methodos) literally means a pursuit of knowledge, investigation, mode of prosecuting such inquiry, or system. In recent centuries it more often means a prescribed process for completing a task. It may refer to:
*Scien ...
of submitting the data,
GET
or
POST
.
Elements
Forms can be made up of standard
graphical user interface
The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
elements:
*
<text>
— a simple
text box
type=search
placeholder=An example text box, which can be used to search the English Wikipedia.
A text box (input box), text field or text entry box is a control element of a graphical user interface, that should enable the user to input ...
that allows input of a single line of text.
*
<email>
- a type of
<text>
that requires a partially validated email address
*
<number>
- a type of
<text>
that requires a number
*
<password>
— similar to
<text>
, it is used for security purposes, in which the characters typed in are invisible or replaced by symbols such as *
*
<radio>
— a
radio button
A radio button or option button is a graphical control element that allows the user to choose only one of a predefined set of mutually exclusive options. The singular property of a radio button makes it distinct from checkboxes, where the user ...
*
<file>
— a
file select In HTML, a file-select control is a component of a web form with which a user can select a local file. When the form is submitted (perhaps together with other form data), the file is uploaded to the web server. There, when the file arrives, some act ...
control for uploading a file
*
<reset>
— a
reset button
In electronics and technology, a reset button is a button that can reset a device. On video game consoles, the reset button restarts the game, forfeiting the player's unsaved progress. On personal computers,On IBM mainframes reset neither c ...
that, when activated, tells the browser to restore the values to their initial values.
*
<submit>
— a
button
A button is a fastener that joins two pieces of fabric together by slipping through a loop or by sliding through a buttonhole.
In modern clothing and fashion design, buttons are commonly made of plastic but also may be made of metal, wood, o ...
that tells the browser to take action on the form (typically to send it to a server)
*
<textarea>
— much like the
<text>
input field except a
<textarea>
allows for multiple rows of data to be shown and entered
*
<select>
— a
drop-down list
A drop-down list (abbreviated drop-down, or DDL; also known as a drop-down menu, drop menu, pull-down list, picklist) is a graphical control element, similar to a list box, that allows the user to choose one value from a list. When a drop-dow ...
that displays a list of items a user can select from
The sample image on the right shows most of these elements:
* a text box asking for your name
* a pair of radio buttons asking you to pick your sex
* a
select box giving you a list of eye colors to choose from
* a pair of check boxes to click on if they apply to you
* a text area to describe your athletic ability
* a submit button to send it to the server
These basic elements provide most common
graphical user interface
The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
(GUI) elements, but not all. For example, there are no equivalents to a
tree view
In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are u ...
or
grid view
A grid view or a datagrid is a graphical control element that presents a tabular view of data. A typical grid view also supports some or all of the following:
* Clicking a ''column header'' to change the sort order of the grid
* Dragging co ...
.
A grid view, however, can be mimicked by using a standard HTML
table
Table may refer to:
* Table (furniture), a piece of furniture with a flat surface and one or more legs
* Table (landform), a flat area of land
* Table (information), a data arrangement with rows and columns
* Table (database), how the table data ...
with each cell containing a text input element. A tree view could also be mimicked through nested tables or, more
semantically
Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference, meaning, or truth. The term can be used to refer to subfields of several distinct disciplines, including philosophy, linguistics and comput ...
appropriately, nested
lists
A ''list'' is any set of items in a row. List or lists may also refer to:
People
* List (surname)
Organizations
* List College, an undergraduate division of the Jewish Theological Seminary of America
* SC Germania List, German rugby unio ...
. In both cases, a server-side process is responsible for processing the information, while JavaScript handles the user-interaction. Implementations of these interface elements are available through
JavaScript libraries A JavaScript library is a library of pre-written JavaScript code that allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies.
Libraries
With the expanded demands for JavaScript, an e ...
such as
jQuery
jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax. It is free, open-source software using the permissive MIT License. As of Aug 2022, jQuery is used ...
.
HTML 4 introduced the
<label>
tag, which is intended to represent a caption in a user interface, and can be associated with a specific form control by specifying the
id
attribute
Attribute may refer to:
* Attribute (philosophy), an extrinsic property of an object
* Attribute (research), a characteristic of an object
* Grammatical modifier, in natural languages
* Attribute (computing), a specification that defines a prope ...
of the control in the label tag's
for
attribute. This allows labels to stay with their elements when a window is resized and to allow more desktop-like functionality (e.g. clicking a radio button or checkbox's label will activate the associated input element).
HTML 5 introduces a number of input tags that can be represented by other interface elements. Some are based upon text input fields and are intended to input and validate specific common data. These include
<email>
to enter email addresses,
<tel>
for telephone numbers,
<number>
for numeric values. There are additional attributes to specify required fields, fields that should have keyboard
focus
Focus, or its plural form foci may refer to:
Arts
* Focus or Focus Festival, former name of the Adelaide Fringe arts festival in South Australia Film
*''Focus'', a 1962 TV film starring James Whitmore
* ''Focus'' (2001 film), a 2001 film based ...
when the web page containing the form is loaded, and placeholder text that is displayed within the field but is not user input (such as the 'Search' text displayed in many search input fields before a search term is entered). These tasks used to be handled with
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, but had become so common that support for them was added to the standard. The
<date>
input type displays a calendar from which the user can select a date or date range.
And the
color
input type can be represented as an input text simply checking the value entered is a correct hexadecimal representation of a color, according to the specification,
or a color picker widget (the latter being the solution used in most browsers which support this attribute).
Submission
When data that has been entered into HTML forms is submitted, the names and values in the form elements are encoded and sent to the server in an
HTTP
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
request message using
GET
Get or GET may refer to:
* Get (animal), the offspring of an animal
* Get (divorce document), in Jewish religious law
* GET (HTTP), a type of HTTP request
* "Get" (song), by the Groggers
* Georgia Time, used in the Republic of Georgia
* Get AS, a ...
or
POST
Post or POST commonly refers to:
*Mail, the postal system, especially in Commonwealth of Nations countries
**An Post, the Irish national postal service
**Canada Post, Canadian postal service
**Deutsche Post, German postal service
**Iraqi Post, Ira ...
. Historically, an
email
Electronic mail (email or e-mail) is a method of exchanging messages ("mail") between people using electronic devices. Email was thus conceived as the electronic ( digital) version of, or counterpart to, mail, at a time when "mail" meant ...
transport was also used. The default
MIME type (internet media type),
application/x-www-form-urlencoded
Percent-encoding, also known as URL encoding, is a method to encode arbitrary data in a Uniform Resource Identifier (URI) using only the limited US-ASCII characters legal within a URI. Although it is known as ''URL encoding'', it is also used m ...
, is based on a very early version of the general URI
percent-encoding
Percent-encoding, also known as URL encoding, is a method to encode arbitrary data in a Uniform Resource Identifier (URI) using only the limited US-ASCII characters legal within a URI. Although it is known as ''URL encoding'', it is also used ...
rules, with a number of modifications such as
newline normalization and replacing spaces with "
+
" instead of "
%20
". Another possible encoding, Internet media type