Adding Labels to a Form
The label provides some context for each element in a form.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<form method="post" action="http://yourServer/form">
<p>
<label for="fave">Survey: <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>
The labels and inputs are associated with for
attribute from label and id attribute from input element.
Home
HTML CSS Book
HTML
HTML CSS Book
HTML
form:
- <form> to get user input
- Using the base Element to Set a Destination for Form Data
- Configuring the HTTP method Attribute for Form element
- Configuring the Form Data Encoding
- Controlling Form Completion
- Specifying a Target for the Form Response
- Setting the Name of the Form
- Adding Labels to a Form
- Automatically Focusing on an input Element
- Disabling Individual input Elements
- Form Elements Outside the Form
Related: