The <input> Element
The most important form element is the<input>
element. The
<input>
element can be displayed in several ways, depending on the type
attribute.Example:
<input name="firstname" type="text">
If the
type
attribute is omitted, the input field gets the default type:
"text".The <select> Element
The<select>
element defines a drop-down list:
<!DOCTYPE html>
<html>
<body>
<h2>The select Element</h2>
<p>The select element defines a drop-down list:</p>
<form action="/action_page.php">
<select name="Paulinfo">
<option value="paultutorial">Paul Tutorial</option>
<option value="News Paul">News Paul</option>
<option value="Digitalworldnewspaper">Digital World Newspaper</option>
</select>
<br><br>
<input type="submit">
</form>
</body>
</html>
The
<option>
elements 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 the
selected
attribute
to the option:Example:
<option value="fiat" selected>Fiat</option>
Visible Values:
Use thesize
attribute to specify the number of visible values:Example:
<select name="paultutorial" size="3">
<option value="paultutorial">paultutorial</option>
<option value="paultutorial2">paultutorial2</option>
<option value="paultutorial3">paultutorial3</option>
<option value="paultutorial4">paultutorial4</option>
</select>
Allow Multiple Selections:
Use themultiple
attribute to allow the user to select more than one value:The <textarea> Element
The<textarea>
element defines a multi-line input field (a text area):
<textarea name="message" rows="10" cols="30">
This is Paul Tutorial
</textarea>
HTML Form Elements
=
new in HTML5.
Tag | Description |
---|---|
<form> | Defines an HTML form for user input |
<input> | Defines an input control |
<textarea> | Defines a multiline input control (text area) |
<label> | Defines a label for an <input> element |
<fieldset> | Groups related elements in a form |
<legend> | Defines a caption for a <fieldset> element |
<select> | Defines a drop-down list |
<optgroup> | Defines a group of related options in a drop-down list |
<option> | Defines an option in a drop-down list |
<button> | Defines a clickable button |
<datalist> | Specifies a list of pre-defined options for input controls |
<output> | Defines the result of a calculation |
No comments:
Post a Comment