Update: A solution is now included with the files.
Fun facts about forms
- A form is first-and-foremost defined by the elements between
</form>tags. There might be many text fields, radio buttons, and checkboxes, but if they all appear inside a single set of
<form>tags, that’s one form.
- Forms usually have at least two attributes, called
action. The two options for
post, and the
actionspecifies a file to process the form when it gets submitted. So usually we’ll write something like
<form id="contact" method="post" action="email-sender.php"">. We’ll go over these details later.
- Most form elements are inline by default, and inline HTML elements need to be contained by block level elements to be valid. This is why you see so many pointless-looking
<div>tags in forms.
- The most common form elements — text inputs, textareas, and submit buttons — require illogical-looking markup. Pay special attention to the
typeattribute whenever you see an
Form element Markup Output A single-line text field
<input type="text" />
A multiline text area
<textarea rows="5" cols="20">I suppose some placeholder text could go here, but most people leave it out.</textarea>
A “submit” button that sends a form
<input type="submit" value="Submit Form!" />