HTML and CSS Reference
<legend>Select your preferred format</legend>
<input type="radio" id="text" name="format" value="text"> Plain text
<input type="radio" id="html" name="format" value="html"> HTML
The label element describing the e-mail field doesn't enclose its associated input element, but they're
connected by the for and id attributes. The labels for the format options contain both their label text and
their input s, so their for attributes aren't strictly necessary but are still worth including. A label element
that lacks a for attribute and doesn't contain a control won't do much good at all; there's nothing to relate
that label to a form control.
You can see the final product in Figure 8-27. Alas, it's not very pretty when you see it with the browser's
default styling. Fortunately you have the power of CSS on your side, and you'll learn just a few ways to
improve the looks of your forms before the end of this chapter.
Figure 8-27 . The form isn't the prettiest thing when rendered with a browser's default style sheet, but its markup is
semantically sound and will be accessible to a wide range of people and devices.
The label element doesn't require any attributes.