Form Elements
Next ❯Input Types
- Tags are:
<button>, <fieldset>, <form>, <label>, <legend>, <input>, <option>, <optgroup>, <select>, <textarea>
- turned_in_notAll Form Elements Used
<!DOCTYPE html> <html> <head><title>All Form Elements Used</title></head> <body> <form> <fieldset> <legend>All Elements Used</legend> Input: <input type="text"> <label>label select</label>< Select:<select name="code"> <option value="html">HTML</option> <option value="css">CSS</option> <option value="javascript">JavaScript</option> </select><br> <label>label Optgroups</label> Select multiple: <select> <optgroup label="mobile"> <option value="1">Option 1</option> <option value="2">Option 2</option> </optgroup> <optgroup label="color"> <option value="3">Option 3</option> <option value="4">Option 4</option> </optgroup> </select><br> TextArea:<textarea name="story" rows="5" cols="20">The Is the TextArea</textarea><br> <button type="button" onclick="alert('Hello, I am a button')">Click Me!</button> </fieldset> </form> </body> </html>
You get OUTPUT:
- Alert! You will get above output, because of not using css So, don't get confuse
OUTPUT:
<fieldset>
element is used to group related data in a form.<legend>
element defines a caption or Heading for the<fieldset>
element.
Input Element
- We have Single Input element but of many Types
- Syntax:
<input type="Input_Type">
- trending_downInput Types
Input Type Description
Input Type Description text
Single Line text field password
Single line Password Field (Mainly used for sensitive information) submit
Used to submit your form automatically by just clicking on it reset
To rest the Form Fields radio
Used when one option is required out of many options checkbox
Used when more than one option is required to be selected button
Can create button from this option also hidden
Used when any fixed data has to be send on the server File
Used When to upload any file to the server image
To create image type button - All the Input Types are discuss in next chapter
- trending_downHTML5 Input TypesLATEST
Input Type Description
Input Type Description color
Input Color Field date
A Date (Format: Year, Month, Day) datetime-local
A date and time with no time zone information email
To accept only email value month
Date contains Year & Month number
To accept only numerical value range
To accept value from a range of numbers search
It is used for search fields tel
To accept only telephone number time
Time contains (Hour, Minute, Seconds, Fractional Seconds) url
To accept only URL value week
To accept only date, contains Year & week - You can Learn this Types in HTML5 Tutorial
*Now Mostly Websites are also using HTML5 Input Type
TextArea Element
It Defines a multi-line input field
- Tag used:
<textarea>
- turned_in_notSample Example
<!DOCTYPE html> <html> <head><title>TextArea Input Example</title></head> <body> <form> Description: <br> <textarea rows="5" cols="20" name="description"> Enter your description here... </textarea> </form> </body> </html>
OUTPUT:
Description:- rows - Specifies the visible height of text area
cols - Specifies the visible width of text area
- rows - Specifies the visible height of text area
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser
Select Element
It provides a drop-down list
- Tag used:
<select>, <option>, <optgroup>
- turned_in_notSample Example
<!DOCTYPE html> <html> <head><title>Select Element Example</title></head> <body> <form> <label>label select</label> Select:<select name="code"><br> <option value="html">HTML</option> <option value="css">CSS</option> <option value="javascript">JavaScript</option> </select><br> <label>label Optgroups</label><br> Select Mobile: <select> <optgroup label="Apple"> <option value="1">iphone 6</option> <option value="2" selected>iphone 7</option> </optgroup> <optgroup label="Orange"> <option value="3">Orange 3</option> <option value="4">Orange 5</option> </optgroup> </select> </form> </body> </html>
OUTPUT:
Select:
Select Mobile:<option>
tag defines an option that can be selected- By default, the first item in the drop-down list is selected
- To define a pre-selected option, add "selected" keyword inside the
<option>
tag <optgroup>
tag is used to group related types of options in single drop-down list- To select multiple options use "multiple" keyword inside the
<select>
tag, and use 'CTRL' key while selecting, to select more options
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser
Button Element
It used to create a clickable button
- Tag used:
<button>
- turned_in_notSample Example
<!DOCTYPE html> <html> <head><title>Button Example</title></head> <body> <button onclick="alert('Hello World!')">Click Me!</button> </body> </html>
OUTPUT:
<button>
tag can be used out of<form>
tag also
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser
Fieldset Element
- Tag used:
<fieldset>, <legend>
- turned_in_notSample Example
OUTPUT:<!DOCTYPE html> <html> <head><title>Fieldset Example</title></head> <body> <form> <fieldset> <legend>Name</legend> First Name: <input type="text"><br> Last Name: <input type="text"><br> </fieldset> </form> </body> </html>
<fieldset>
element is used to group related data in a form.<legend>
element defines a caption or Heading for the<fieldset>
element.
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser
❮ Prev Form Action
Next ❯Input Types