HTML CSS examples for HTML Tag:label
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 Convention | label { cursor: default; } |
The following code shows how you can give the user some context.
<!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>