What are these HTML form fields for?

forms, html

Solution

Labels are pieces of text next to input fields - they don't look any different from normal text, but:

- clicking on them puts the focus on the field

- screenreaders will read them out as a description of the corresponding field.

They are also be useful for CSS - by using labels, you can easily style your field labels independently of other page elements.

The `form name` attribute makes it easier to reference the form from JavaScript (though these days you'd use `id` for that).

Problem

I saw some code, html form code which looks like this: ``` <form name="form1" method="post" action="action.php"> <label for="name"> Name: <input type="text" name="name"> <label for="email">Email: <input type="text" name="email"> </form> ``` What are the form "name" for? (-> form1) What are the label tag for? (i never use this, so, i might wrong when enter the code)

Original source