During User Registration, users often need to focus the cursor on the corresponding form when they click the text. How is this implemented? The for Attribute of the <label> label
Definition: for Attribute specifies the form element to which the label is bound
[HTML]View plaincopy
- <! --
- Explicit contact:
- <Label for = "SSN"> Social Security Number: </label>
- <Input type = "text" name = "socsecnum" id = "SSN"/>
- Implicit contact:
- <Label> Date of Birth: <input type = "text" name = "dofb"/> </label>
- -->
The following is an example:
[HTML]View plaincopy
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
- <Title> untitled document </title>
- </Head>
- <Body>
- <Table>
- <Tr>
- <TD> <label for = "username"> User name: </label> </TD>
- <TD> <input type = "text" name = "username" id = "username"> </TD>
- </Tr>
- <Tr>
- <TD> <label for = "password"> password: </label> </TD>
- <TD> <input type = "password" name = "password" id = "password"> </TD>
- </Tr>
- <Tr>
- <TD> <label for = "repassword"> confirm the password: </label> </TD>
- <TD> <input type = "password" name = "repassword" id = "repassword"> </TD>
- </Tr>
- <Tr>
- <TD> <label for = "_ basketball"> Hobbies: </label> </TD>
- <TD>
- <Label> <input type = "checkbox" value = "basketball" name = "holobby" id = "_ basketball"> basketball </label>
- <Label> <input type = "checkbox" value = "football" name = "holobby" id = "_ football"> football </label>
- <Label> <input type = "checkbox" value = "skating" name = "holobby" id = "_ skating"> skating </label>
- <Label> <input type = "checkbox" value = "dance" name = "holobby" id = "_ Dance"> dance </label>
- </TD>
- </Tr>
- <Tr>
- <TD> <label for = "_ boy"> Gender: </label> </TD>
- <TD>
- <Label> <input type = "radio" value = "boy" name = "sex" id = "_ boy"> boy </label>
- <Label> <input type = "radio" value = "girl" name = "sex"> girl </label>
- </TD>
- </Tr>
- <Tr>
- <TD> <label for = "email"> Email: <label> </TD>
- <TD> <input type = "text" name = "email" id = "email"> </TD>
- </Tr>
- <Tr>
- <TD> <label for = "Address"> address: </label> </TD>
- <TD> <input type = "text" name = "Address" id = "Address"> </TD>
- </Tr>
- </Table>
- </Body>
- </Html>
<Label> usage of the label for Attribute