HTML
HTML
Programming
HTML Forms
Text files
HTML Forms
HTML Forms are used to select different kinds of user input.
• The <form> element defines an HTML form:
<form>
form elements goes here…
</form>
• Form elements allow the user to enter information (like text fields, submit
buttons, drop-down menus, radio buttons, checkboxes, etc.) in a form.
HTML Form Elements
<input> element:
e1_form-input>>
<form>
<label>First name:</label><br>
<input type="text" name="firstname">
</form>
HTML Forms (Input Types)
Input of type: (text, password, submit, button, radio, checkbox, hidden, file,
image, reset)
● <input type="text"> defines a one-line input field for text input.
● <input type="radio"> defines a radio button. Radio buttons let a user select
ONLY ONE of a limited number of choices.
<select name=“city">
<option value=“Duhok"> Duhok </option>
<option value=“hawler">Hawler</option>
<option value=“sul">Sulaymania</option>
<option value=“halabja">Halabja</option>
</select>
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
HTML Form Elements
• <fieldset> and <legend> elements:
e6_form-fieldset>>
<form>
<fieldset>
<legend>Personal data:</legend>
Name: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
HTML Forms (HTML5 Input Types)
HTML5 added several new input types:
color, date, datetime-local, time, month, week, email, number, range, search,
tel, url .
NOTE:
• Some input types not supported by some browser..
• Input types that not supported by old web browsers, will behave as input type
text.
The <input type="color"> is used for input fields that should contain a color.
Depending on browser support, a color picker can show up in the input field.
This allows the user to select a date and time (no time zone).
<input type="datetime-local"
name=“dob">
HTML Forms (HTML5 Input Types)
• Input type: time >> example slide>>
Used for input fields that should contain a numeric value. You can set
restrictions on the numbers.
Used for search fields (search field behaves like a regular text field).
Used for input fields that should contain a URL address. Depending on browser
support, the url field can be automatically validated when submitted.
<video> tag :
e1_video>>
<embed src="audi.jpg">
e6_object-embed>>
<object width=“500" height=“300" data=“Lec-6-HTML.pdf"></object>
<embed width=“500" height=“300" src=" Lec-6-HTML.pdf“>
Thanks for Listening