<label> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:label

Introduction

By using the label element, you provide some context for each element in a form.

The label Element summary

Item Value
Element: label
Local Attributes:for, form
Contents:Phrasing Content
Tag Style: Start and end tags
New in HTML5?No
Changes in HTML5 The form attribute has been added in HTML5.
Style Conventionlabel { cursor: default; }

The following code shows how you can give the user some context.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form method="post" action="http://example.com/form"> 
         <p>
            <label for="fave">
               Fruit: <!--   w w  w  .  j  av  a2s  . c o  m-->
               <input id="fave" name="fave">
            </label>
         </p> 
         <p>
            <label for="name">
               Name: 
               <input id="name" name="name">
            </label>
         </p> 
         <button>Submit Vote</button> 
      </form>  
   </body>
</html>

Related Tutorials