Except where otherwise noted, the contents of this presentation are © Copyright 2008 Marty Stepp and Jessica Miller and are licensed under the Creative Commons Attribution 2.5 License.
<button>
the most common clickable UI widget (inline)
<button>Click me!</button>
button
tagimg
) and other content<input>
sets of mutually exclusive choices (inline)
<input type="radio" name="creditcards" /> Visa <input type="radio" name="creditcards" /> MasterCard <input type="radio" name="creditcards" checked="checked" /> American Express
name
attribute (only one can be checked at a time)<label>
<label><input type="radio" name="creditcards" /> Visa</label> <label><input type="radio" name="creditcards" /> MasterCard</label> <label><input type="radio" name="creditcards" /> American Express</label>
label
element can be targeted by CSS style rules<input>
an on/off toggle (inline)
<label><input type="checkbox" /> Lettuce</label> <label><input type="checkbox" checked="checked" /> Tomato</label> <label><input type="checkbox" /> Pickles</label>
input
element is used to create many UI controls
checked="checked"
attribute in HTML to initially check the box<input>
<input type="text" size="12" maxlength="8" /> NetID<br /> <input type="password" size="12" /> Password
input
attributes: disabled
, maxlength
, name
, readonly
, size
, type
, value
size
attribute controls onscreen width of text fieldmaxlength
limits how many characters user is able to type into field<textarea>
a multi-line text input area (inline)
<textarea rows="4" cols="20"> Type your comments here. </textarea>
textarea
tag (optional)rows
and cols
attributes specify size in charactersreadonly
attribute means text cannot be modified<select>
,
<option>
menus of choices that collapse and expand (inline)
<select> <option>Jerry</option> <option>George</option> <option>Kramer</option> <option>Elaine</option> </select>
option
element represents each choiceselect
optional attributes: disabled
, multiple
, size
<select>
for lists<select size="3" multiple="multiple"> <option>Jerry</option> <option>George</option> <option>Kramer</option> <option>Elaine</option> <option selected="selected">Newman</option> <option>Susan</option> </select>
size
attribute controls how many items can be seen (default 1)multiple
attribute allows selecting multiple items with shift- or ctrl-clickoption
tags can be set to be initially selected
<optgroup>
<select> <optgroup label="Major Characters"> <option>Jerry</option> <option>George</option> <option>Kramer</option> <option>Elaine</option> </optgroup> <optgroup label="Minor Characters"> <option>Newman</option> <option>Susan</option> </optgroup> </select>
<fieldset>
,
<legend>
groups of input fields with optional caption (block)
<fieldset> <legend>Credit cards:</legend> <label><input type="radio" name="creditcards" /> Visa</label> <label><input type="radio" name="creditcards" /> MasterCard</label> <label><input type="radio" name="creditcards" /> American Express</label> </fieldset>
fieldset
groups related input fields; legend
supplies an optional captionfieldset
and legend
can be targeted by CSS style rulesI changed the checkbox'schecked
property, thetextarea
's inner text, the text box'svalue
... but when I refresh, the page doesn't reflect this change!
element[attribute="value"] { property : value; property : value; ... property : value; }
input[type="text"] { background-color: yellow; font-style: bold; }
input
)<textarea rows="3" cols="40"></textarea>
body { height: 100%; } textarea { position: absolute; width: 50%; height: 15%; }
rows
and cols
on a textarea
textarea
at a specific width/height in pixels or %, you must specify rows
/cols
in the XHTML and width
/height
in the CSS
rows
/cols
will be ignored but must be there anyway...height
on the page's body
helpstextarea
helpsbody
or head
(BAD STYLE).js
file, linked to the XHTML file in its head
(good style)
<script src="filename" type="text/javascript"></script>
<script src="example.js" type="text/javascript"></script>
head
.js
filefunction name() { statement ; statement ; ... statement ; }
alert
box
alert("message");
alert("IE6 detected. Suck-mode enabled.");
function myFunction() { alert("Hello!"); alert("How are you?"); }
example.js
linked to our XHTML document
<button onclick="myFunction();">Click me!</button>
onclick
is just one of many event HTML attributes we'll see later<select onchange="myFunction();"> <option>Jerry</option> <option>George</option> <option>Kramer</option> <option>Elaine</option> </select>
onchange
event occursonabort
,
onblur
,
onchange
,
onclick
,
ondblclick
,
onerror
,
onfocus
,
onkeydown
,
onkeypress
,
onkeyup
,
onload
,
onmousedown
,
onmousemove
,
onmouseout
,
onmouseover
,
onmouseup
,
onreset
,
onresize
,
onselect
,
onsubmit
,
onunload