<Label> usage of the label for Attribute

Source: Internet
Author: User

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
  1. <! --
  2. Explicit contact:
  3. <Label for = "SSN"> Social Security Number: </label>
  4. <Input type = "text" name = "socsecnum" id = "SSN"/>
  5. Implicit contact:
  6. <Label> Date of Birth: <input type = "text" name = "dofb"/> </label>
  7. -->


The following is an example:

[HTML]View plaincopy
    1. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <HTML xmlns = "http://www.w3.org/1999/xhtml">
    3. <Head>
    4. <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
    5. <Title> untitled document </title>
    6. </Head>
    7. <Body>
    8. <Table>
    9. <Tr>
    10. <TD> <label for = "username"> User name: </label> </TD>
    11. <TD> <input type = "text" name = "username" id = "username"> </TD>
    12. </Tr>
    13. <Tr>
    14. <TD> <label for = "password"> password: </label> </TD>
    15. <TD> <input type = "password" name = "password" id = "password"> </TD>
    16. </Tr>
    17. <Tr>
    18. <TD> <label for = "repassword"> confirm the password: </label> </TD>
    19. <TD> <input type = "password" name = "repassword" id = "repassword"> </TD>
    20. </Tr>
    21. <Tr>
    22. <TD> <label for = "_ basketball"> Hobbies: </label> </TD>
    23. <TD>
    24. <Label> <input type = "checkbox" value = "basketball" name = "holobby" id = "_ basketball"> basketball </label>
    25. <Label> <input type = "checkbox" value = "football" name = "holobby" id = "_ football"> football </label>
    26. <Label> <input type = "checkbox" value = "skating" name = "holobby" id = "_ skating"> skating </label>
    27. <Label> <input type = "checkbox" value = "dance" name = "holobby" id = "_ Dance"> dance </label>
    28. </TD>
    29. </Tr>
    30. <Tr>
    31. <TD> <label for = "_ boy"> Gender: </label> </TD>
    32. <TD>
    33. <Label> <input type = "radio" value = "boy" name = "sex" id = "_ boy"> boy </label>
    34. <Label> <input type = "radio" value = "girl" name = "sex"> girl </label>
    35. </TD>
    36. </Tr>
    37. <Tr>
    38. <TD> <label for = "email"> Email: <label> </TD>
    39. <TD> <input type = "text" name = "email" id = "email"> </TD>
    40. </Tr>
    41. <Tr>
    42. <TD> <label for = "Address"> address: </label> </TD>
    43. <TD> <input type = "text" name = "Address" id = "Address"> </TD>
    44. </Tr>
    45. </Table>
    46. </Body>
    47. </Html>

<Label> usage of the label for Attribute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.