HTML Tables and Forms (PDFDrive)
HTML Tables and Forms (PDFDrive)
Forms
Chapter 5
th
• Popular in 1990s
• Results in table bloat
• Not semantic
• Larger HTML pages
• Longer load time
• Password input
• Options Lists
Types of forms:
– Search form, Order form, Newsletter sign-up
form, Survey form, Add to Cart form, Login form,
and so on…
<input> <option>
<textarea> <optgroup>
<button> <fieldset>
<select>
<label>
• text • radio
• password • checkbox
• hidden • submit
• reset
25
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
type="text"
38
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
Accessible Forms
Recall the <fieldset>, <legend>, and <label> elements.
Each <label> element should be associated with a
single input element.
<p>Client Type:
<label> <input type="radio" name="type" value="School">School</label>
<label><input type="radio" name="type" value="College">College</label>
<label><input type="radio" name="type" value="University">University</label>
</p>
<label>
<input type="radio" name= "crust" value= "hand"> Hand
Tossed
</label>
Or
<label for="email" >Email: </label>
<input type="text" name="CustEmail" id= "email">
42
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
Fieldset and Legend Elements
The Fieldset Element
– Container tag
– Creates a visual group of
form elements on a web
page
The Legend Element
– Container tag
– Creates a text label within
the fieldset
<fieldset><legend>Customer Information</legend>
<label>Name:
<input type="text" name=“name" id="Name"></label>
<br><br>
<label>Email:
<input type="text" name="Email" id="Email"></label>
</fieldset>
43
Randy Connolly and Ricardo Hoar Fundamentals of Web Development
How forms interact with servers
GET
Data can be clearly seen in the address bar.
Data remains in browser history and cache.
Data can be bookmarked
Limit on the number of characters in the form
data returned.
POST
Data can contain binary data.
Data is hidden from user.
Submitted data is not stored in cache, history,
or bookmarks.
<input type="file">
time Creates a time input control. The format for the time is
"HH:MM:SS", for hours:minutes:seconds.
datetime Creates a control in which the user can enter a date and time.
datetime- Creates a control in which the user can enter a date and time
local without specifying a time zone.
<label for="address">Address:</label>
<input type="text" name="address" id="address"><br>
<label for="city">City:</label>
<input type="text" name="city" id="city"><br>
<label for="state">State:</label>
<input type="text" name="state" id="state"><br>
3 Introducing Forms
4 Form Control Details
7
Randy Connolly and Ricardo Hoar Fundamentals of Web Development