Page 106 - HTML5
P. 106

Chapter 23: Label Element




        Syntax



            •  <label>Example <input type="radio" name="r"></label> // Wrapping a control Element
            •  <label for="rad1">Example</label> <input id="rad1" type="radio" name="r"> // Using for
              attribute


        Parameters




          Attributes   Description

          for          Reference to the target ID Element. I.e: for="surname"


                       HTML5, [Obsolete] Reference to the form containing the Target Element. Label
          form         elements are expected within a <form> Element. If the form="someFormId" is
                       provided this allows you to place the Label anywhere in the document.



        Examples


        Basic Use


        Simple form with labels...


         <form action="/login" method="POST">

             <label for="username">Username:</label>
             <input id="username" type="text" name="username" />

             <label for="pass">Password:</label>
             <input id="pass" type="password" name="pass" />

             <input type="submit" name="submit" />

         </form>


        5


         <form id="my-form" action="/login" method="POST">

             <input id="username" type="text" name="username" />

             <label for="pass">Password:</label>
             <input id="pass" type="password" name="pass" />

             <input type="submit" name="submit" />

         </form>



        https://riptutorial.com/                                                                               90
   101   102   103   104   105   106   107   108   109   110   111