HTML 5 and CSS 3 – Illustrated 2nd Ed. Instructor’s Manual: Unit J Page 7 of 11
• Explain that check boxes are used in order to present users with a predetermined set of choices; and
you want users to be able to select one or more predefined choices independent of each other.
• Demonstrate the use of a check box by clicking to add or remove a check mark in order to select or
deselect the check box.
• Point out that check boxes are ideal for allowing users to indicate whether a particular statement
applies to them.
TEACHER TIP
To create checkboxes that are preselected when the web form loads, add the checked attribute to
the input element.
FIGURES: J-10, J-11, J–12
BOXES
1. Quick Tip: A check box should always precede its label text for optimal usability.
2. Quick Tip: Different browsers format check boxes differently by default, so the check boxes in your
browser may not match those in the figure.
3. Clues to Use: Marking fields as required
Often one or more fields on a web form are marked as required— that is, fields the user must complete.
Many websites implement scripts to check if required fields are completed; if not, these scripts can prevent
the submission of the form and display an error message. Modern browsers also support the HTML5
required attribute, which can replace script-based verification. You simply add the attribute required
(or required=”required” in XHTML documents) to any required field element. For instance, to
create a text box that users must complete, you use the code <input type=”text” required>. You
should also include a visual cue on your web page for each required field, along with an explanation of what
the cue means. A red asterisk is commonly used to denote required fields on web forms. The required
attribute can’t replace script-based validation for websites that must support older browsers, but it can
supplement script-based validation for many websites.
CLASSROOM ACTIVITIES
1. Critical Thinking: As mentioned before, elements within a form can be nested one inside the other.
Think of forms you have seen and give examples of situations when a check box element is nested
inside another element. What are the advantages of this format?
2. Quick Quiz: