#Building Forms
##HTML Elements for marking up a form
-
form- supports the attributesactionandmethod, among others. -
input- supports the attributestypeandnameamong others. It's self containd and doesn't wrap any other element. HTML5 came along with a few new types ofinput -
color -
email -
range -
time -
date -
month -
search -
url -
datetime -
number -
tel -
week -
textarea- supports the input of larger text spanning multiple lines. attributes likecolsandrowsdetermine the size of input which is diplayed by the control.
###Multiple choice controls
Radio Buttons
These are input elements with type set to radio. Ensure all related options have the same name attribute.
Checkboxes
These are input elements with type set to checkbox. Ensure all related options have the same name attribute.
Drop Down Lists
These are created by the combination of select and option elements. with the latter neseted witihin the former.
###Form Buttons
inputwithtypeset to submit. Self-contained just like a regularinputbuttonelement withtypeset to submit. Has the advanatage that it can enclose other elements.
###Other Inputs
Besides the already mentioned uses of the input tag, it is also possible to use it in other contexts.
- an
inputof typehiddenallows one to pass data from a form which shouldn't be visible to users. - an
inputof typefileallows users to add a file to a form.
###Organizing Form Elements
Labels
labelto describe the inputs or controls they relate to by using theforattribute. It is also possible to wrap target content with thelabelelement.
Fieldsets
fieldsets, much likesectionwrap related content together within a form for better organization. They include a border outline which may be styled using CSS.
Legends
legends provide the caption or heading for thefieldsetelement. Thelegendelement should be the first child element within afieldsetas it wraps the rest of the content within the fieldset.
###Form & Input Attributes
disabled- affects all nested elements if applied to afieldset, also ifapplied to an hiddeninput, makes it ignored.placeholder- to provide hints of what's expected in an input field.required- ensures that an element contains a value before it can be submitted to the server. Validation is specific to the type of control e.g.requiredon an emailinputwill not only ensure that an input is supplied but that it is also a valid input.acceptformactionformnovalidatemaxlengthreadonlyautocompleteformenctypeformtargetminmaxselectionDirectionautofocusformmethodpatternstep