Students Empire

Learn Something New
Home

form label




The label element provides some context for each element in a form. It has local Attributes: for, form .


		            <!DOCTYPE HTML>
		            <html>
		            <body>
		            <form method="post" action="">
		            <p>
		            <label for="fave">Fruit: <input id="fave" name="fave"></label>
		            </p>
		            <p>
		            <label for="name">Name: <input id="name" name="name"></label>
		            </p>
		            <button>Submit</button>
		            </form>
		            </body>
		            </html>
		      

An id attribute is added to the input elements and label is using these ids as the value for the for attributes on the label elements. This is how you associate labels with inputs