URL: http://www.sitepoint.com/article/1273

Simon Willison has written a nice article about Simple tricks for more usable forms and from it I learned about how <label> tags work. They have been part of HTML since 1998 so today most browsers should support them; and if not, it's not a show-stopper. What they do is that they help to associate a text with an input field. For example, here, mouseclick the word "Name" and "Agree?" below.

Name
Agree?

Nothing happens! Instead, with <label> tags, notice the difference when you mouseclick the words "Name" and "Agree?"


For code for the latter example is:


<form>
<label for="name2"><b>Name</b></label>  
<input name="var21" id="name2"><br>
<label for="agree2">Agree?</label>
<input type="checkbox" name="var22" id="agree2">
</form>

Comments

what

does not work

greenwald

whats the point?

Your email will never ever be published.

Previous:
Robots.txt Validator January 24, 2004 Web development
Next:
Dabbrev in Jed January 26, 2004 Linux
Related by category:
Fastest way to find out if a file exists in S3 (with boto3) June 16, 2017 Web development
Be very careful with your add_header in Nginx! You might make your site insecure February 11, 2018 Web development
<datalist> looks great on mobile devices August 28, 2020 Web development
How to have default/initial values in a Django form that is bound and rendered January 10, 2020 Web development
Related by keyword:
Command-Enter to submit a form when focus is inside textarea with React (TypeScript) February 4, 2022 React
How to have default/initial values in a Django form that is bound and rendered January 10, 2020 Python, Web development, Django
Button tag in bloody Internet Explorer August 9, 2005 Web development
Automatically strip whitespace in Django forms October 12, 2009 Django