HTML Session 5
HTML Forms
• An HTML form is used to collect user input.
• The user input is most often sent to a server for processing.
The <form> Element
• The HTML <form> element is used
to create an HTML form for user
input.
• The <form> element is a container
for different types of input elements,
such as: text fields, checkboxes, radio
buttons, submit buttons, etc.
The <label> Element
• The <label> tag defines a label for many form elements.
The <input> Element
Here are some examples :
• The HTML <input> element is the
most used form element.
• An <input> element can be
displayed in many ways, depending
on the type attribute.
Input Type Text
• <input type="text"> defines a single-line text input field :
The placeholder Attribute
• The input placeholder attribute specifies a short hint that
describes the expected value of an input field.
• The short hint is displayed in the input field before the user
enters a value.
Input Type email
• <input type=“email"> is used for input fields that should
contain an e-mail address.
Input Type number
• <input type=“number"> is defines a numeric input
field.
Input Type Password
• <input type=“password"> is defines a password field:
• The characters in a password field are masked
(shown as asterisks or circles).
The <select> Element
• The <select> element defines a drop-down list.
• The <option> element defines an option that can be selected.
• The name attribute specifies the name of an <input> element.
• The name attribute is used to reference elements in a JavaScript, or to
reference form data after a form is submitted.
The <textarea> Element
• The <textarea> element defines a multi-line input field (a text area):
• The rows attribute specifies the visible number of lines in a text area.
• The cols attribute specifies the visible width of a text area.
Input Type Submit
• <input type=“submit"> is defines a button for
submitting form data to a form-handler.
• It is usually displayed with submit.
• We use attribute value to display a different value instead of
submit
Home work
Make this web page: