HTML Reference
<th>
Full name
Table Header
Description
Represents a single header cell in a table.
Context
May be used inside a <tr> element.
Attributes
colspan
Determines over how many columns the header extends.
rowspan
Determines over how many r ows the header extends.
Example
See < table> example on page 328.
<tr>
Full name Table Row
Description Holds a row o f cells in a table.
Context May be u sed as a child of a <table> element and it must
appear after the <ca ption> element, if the table ha s one.
Example
See < table> example on page 328.
C.9 Forms
<form>
Description
Represents an assemblage of interactive form-control ele-
ments that collect data from a user. The collected data can
be sent to a server for further processing.
Content Cannot contain any other <form> elements.
C.9. Forms 329
Display Block
Attributes
action
This attribute is used at form submission. It specifies a server-side program that should
process submitted data. In HTML5, the action attribute is no longe r required as it
was in HTML4.
autocomplete
Determines whether a browser can automatically complete the values of the controls
in this form. Using the autocomplete attribute on a specific element can override
this value. This attribute can have one of two possible values:
on: The browser is a llowed to automatically complete values ac cording to the
values that have been entered dur ing previous uses of the form.
off: The user must explicitly input every piece of information each time, or the
document will provide its own method of autocompletion. The browser will not
automatically complete entries.
If this attribute is not set, then the default value on is assumed.
method
Specifies the HTTP method th e browser will use to submit the form. T he two most
commonly used methods are:
get: By this method, the form data is URL enco ded with a question mark (?)
as a separator.
post: If the form uses this method, then the entered data will be sent in the
message body.
Example
<form action="eat_this.asp" method="get">
<!-- Here come different input controls such as buttons, text
boxes, radio buttons, etc. -->
</form>
330 HTML Reference
HTML Reference
<input>
Description
Represents a typed data field, most often with a form control
for the user to edit th e data.
Context Usually, it is used as a descendant of a <form > element. If
not, then it should have specified the form attribute.
Content This is a void element.
Display Inline
Attributes
autocomplete
This attribute determine s whether the browser can automatically complete the value
of the control. It has one of two possible values:
on: The browser is a llowed to automatically complete values ac cording to the
values that have been entered dur ing the previous uses of the form.
off: The user must enter a complete value in to this field each time, or the
document will provide its own method of autocompletion. The browser will not
automatically complete entries.
If this attribute is not set, then the browser uses the autocomplete attribute value of
the <form> element to which this <input> element belongs. The < input> element
belongs to a form tha t is either its parent, or the <input> element’s form attribute
equals the form’s id attribute value.
checked
This Boolean attribute is used only when the type attribute is set to ch eckbox or
radio, and it is spec ified without a value. If the chec ked attribute is present, then the
control is selected by default.
form
This attribute connects an <input> element with a specific form, which thus become s
the <input> element’s owner. The value of the form attribute must be equ al to the
value of the id attribute of th e form. If this attribute is omitted, then the <input>
element must be a descendant of a <form> eleme nt.
max
Defines the maximum possible value for this control, which must not be smaller than
the value of the min attribute.
C.9. Forms 331
min
Defines the minimum possible value for this control, which must not be greater than
the value of the max attribute.
name
Specifies the name of the control, which is used in form sub mission.
readonly
This is a Boolean attribute a nd is specified without a value. If it is present, then the
visitor cannot modify the value of the control.
step
This attribute is used together with the min and max attributes, and sp ecifies the incre-
ment at which one can set a numeric value.
type
Defines the type of the form c ontrol element. If th is attribute is not given, then the
default value text is a ssumed. Some of the possible values are:
button: A push button.
checkbox: A che ck box . If the type attribute is set to checkbox, then the
value attribute should also be used in order to specify the value submitted with
this item. The checked attr ibute can be used to ind ic ate that the item is initially
selected.
number: A field for entering a floating point number. With the type attribute
set to number, the attributes value, mi n, max, a nd step are often used. If they
are not explicitly set, the default values min = 0, max = 100, and step = 1 are
used.
password: A text field with no line breaks that obscures data entry.
radio: A r adio button. The value that will be submitted by this element is
specified by the value attribute. Au thors can make the item selected by d efault
by including the checked attribute. The radio buttons with the same value of
the name attribute form a group, and only one button in a gro up can be selected
at a time.
reset: A push button that r esets the values of all th e contr ol eleme nts of the
owner form to default values.
submit: A push button that submits the form.
text: A field for entering text with no line breaks.
value
Specifies an initial value of a control. It is optional except whe n the type attribute is
set to radio or checkbo x.
332 HTML Reference
HTML Reference
Examples
<!-- A push button triggering a JavaScript alert box. -->
<input type="button" value="Click me" onclick="alert(’Hi there!’)">
<!-- Select zero or more from the list. -->
<label><input type="checkbox" name="goodies" value="lamp" checked>
Fruits Table Lamp
</label>
<label><input type="checkbox" name="goodies" value="clock">
Kit-Cat Clock
</label>
<label><input type="checkbox" name="goodies" value="tea_set">
Ceramic Tea Set
</label>
<!-- Decide for exactly one of the options. -->
<label><input type="radio" name="offer" value="yes" checked>
Yes, please.
</label>
<label><input type="radio" name="offer" value="no">
No, thanks.
</label>
<!-- Fetch some generic text input. -->
<input type="text" name="opinion" value="Enter your opinion...">
<!-- A button to set all the form controls to default values. -->
<input type="reset">
<!-- Some numeric input -->
<label>Rate this seller
<input type="number" name="rate" min="1" max="10" value="5">
</label>
<label>
Description
Represents a cap tion within a form, which can be associated
with a specific form-control element. The association can
be established either by using the <lab el> element’s for
attribute, or by putting the form- control element inside the
<label> element itself.
C.9. Forms 333
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.58