E-mail List Archives
Re: labels in forms
From: Christian Heilmann
Date: May 31, 2007 6:00PM
- Next message: Jukka K. Korpela: "Re: labels in forms"
- Previous message: Patrick H. Lauke: "Re: labels in forms"
- Next message in Thread: Jukka K. Korpela: "Re: labels in forms"
- Previous message in Thread: Patrick H. Lauke: "Re: labels in forms"
- View all messages in this Thread
> Hi all,
> I'd like some clarity on labels in forms please. Is it OK to put <label
> for="fname"> if it for a first name input box or is it better to put <label
> for="firstname"> or even <label for="first name">. I wasn't sure if screen
> readers and the like actually read the value in the label and whether it is
> best to have something in there that actually makes sense to the visitor or
> if it is fine to use abbreviations.
The for attribute connects with the id of the element it should
connect to. This is only for the browser and will not be read out. As
IDs cannot have spaces "first name" would be wrong. You can call the
ID whatever you please though, with form fields the name attribute is
what is sent to the server. IDs are only in HTML as hooks for CSS and
DOM, and don't have anything to do with the backend or with assistive
<label for="fn">First Name</label><input type="text" name="firstname"
id="fn"> is as valid as <label for="scoobydoo">First
Name</label><input type="text" name="firstname" id="scoobydoo">