WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Site Design > Graphics & Design Discussion Forum > Accessibility and Usability Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Accessibility and Usability Forum Discuss topics related to website accessibility and usability. Subjects include; testing techniques, tutorials, guidelines and legal issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-10-2003, 04:16 PM
WebProWorld Member
 

Join Date: Jul 2003
Posts: 27
cyberRobot RepRank 0
Default Using the label tag with form elements

Does it matter if a form element appears inside of the label tag? For example:

Code:
<label for="email">Email:</label><input type="text" name="email" id="email" />
vs

Code:
<label for="email">Email:<input type="text" name="email" id="email" /></label>
To me the first one makes more sense because the input field itself is not part of the label. I've seen it both ways. Is there a reason for doing it one way over the other?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-10-2003, 08:57 PM
Webnauts's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Worldwide
Posts: 7,399
Webnauts RepRank 3Webnauts RepRank 3
Default

The first issue is the right one. Correct code syntax.
Reply With Quote
  #3 (permalink)  
Old 11-12-2003, 08:37 AM
WebProWorld Member
 

Join Date: Jul 2003
Posts: 27
cyberRobot RepRank 0
Default

Quote:
Originally Posted by Webnauts
The first issue is the right one. Correct code syntax.
Then why does the W3C use the second example?
http://www.w3.org/TR/WCAG10-HTML-TECHS/#forms-labels

They also use the first example:
http://www.w3.org/TR/WCAG10-HTML-TECHS/#forms-grouping

Note: The W3C validator doesn't complain about either of the examples.
Reply With Quote
  #4 (permalink)  
Old 11-12-2003, 09:48 AM
Webnauts's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Worldwide
Posts: 7,399
Webnauts RepRank 3Webnauts RepRank 3
Default Info

You send me links where there is a description about that. Did you read there and not understood?

Here some on-topic resources for further reading and learning:

http://www.seotoolbox.com/html-issues/forms.html
http://www.yourhtmlsource.com/forms/...ssibility.html
http://www.htmlhelp.com/reference/ht...rms/label.html
http://www.webaim.org/techniques/forms/
http://www.netmechanic.com/news/vol5...ility_no19.htm
http://www.evolt.org/article/Form_La...823/index.html

If you still have questions please let me know.
Reply With Quote
  #5 (permalink)  
Old 11-12-2003, 04:12 PM
WebProWorld Member
 

Join Date: Jul 2003
Posts: 27
cyberRobot RepRank 0
Default Re: Info

Quote:
Originally Posted by Webnauts
You send me links where there is a description about that. Did you read there and not understood?
According to the W3C, both methods are valid. (See links from previous post) The W3C validator (http://validator.w3.org/) doesn't seem to mind either way.

I was wondering if there is a difference between the two code examples I gave earlier?
Reply With Quote
  #6 (permalink)  
Old 11-12-2003, 04:30 PM
WebProWorld Member
 

Join Date: Jul 2003
Posts: 27
cyberRobot RepRank 0
Default

Never mind I figured it out. According to the W3C, the following code:

Code:
<LABEL>
   First Name
   <INPUT type="text" name="firstname">
</LABEL>
is used to implicitly associate a label with an input field. (without using the for or id attributes)

Here is the page I got the info from:
http://www.w3.org/TR/html4/interact/forms.html#h-17.9.1

Thanks
Reply With Quote
  #7 (permalink)  
Old 11-12-2003, 07:12 PM
Webnauts's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Worldwide
Posts: 7,399
Webnauts RepRank 3Webnauts RepRank 3
Default

So far I can remember, the above code is not valid in XHTML.
Reply With Quote
  #8 (permalink)  
Old 11-13-2003, 08:23 AM
WebProWorld Member
 

Join Date: Jul 2003
Posts: 27
cyberRobot RepRank 0
Default

Quote:
Originally Posted by Webnauts
So far I can remember, the above code is not valid in XHTML.
The following code from W3C that I mentioned in my last post:
Code:
<LABEL> 
   First Name 
   <INPUT type="text" name="firstname"> 
</LABEL>
is not XHTML complient, because I got it from the HTML 4.01 Specifications page.

The other two examples I gave in my first post are valid XHTML. Note: I validate using XHTML Transitional, so I have no idea if it's valid for XHTML Strict.
Reply With Quote
  #9 (permalink)  
Old 12-08-2003, 09:06 PM
ScottNorton's Avatar
WebProWorld Member
 

Join Date: Jul 2003
Location: Arlington, VA
Posts: 26
ScottNorton RepRank 0
Default Implicit Labels Considered Harmful

Quote:
Originally Posted by cyberRobot
According to the W3C, the following code:

Code:
<LABEL>
   First Name
   <INPUT type="text" name="firstname">
</LABEL>
is used to implicitly associate a label with an input field. (without using the for or id attributes)
The US Government's Access Board states that implicit labels should be avoided, because they are "not reliably supported by many screen readers and, in particular, do not work well if explicit labels are simultaneously used anywhere on the same web page."

http://www.access-board.gov/sec508/g...194.22.htm#(n)
__________________
Scott Norton
DTI Associates, Inc.
SNorton@DTIHQ.com
or Norton@ACM.org
Reply With Quote
  #10 (permalink)  
Old 12-09-2003, 07:11 AM
Webnauts's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Worldwide
Posts: 7,399
Webnauts RepRank 3Webnauts RepRank 3
Default Thanks

Very great and useful information Scott!
Thanks! :)
Reply With Quote
  #11 (permalink)  
Old 12-10-2003, 05:27 AM
Webnauts's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Worldwide
Posts: 7,399
Webnauts RepRank 3Webnauts RepRank 3
Default

Scott Norton, as confusing as that document is worded, it means that if you use explicit labels, use them consistently to label all form elements and avoid having implicit ones (either by design, or by mistake). The best way to avoid problems is to have explicit labels and put them where a screenreader may be expecting implicit ones (e.g. have labels for radio buttons and checkboxes after the box, for text inputs etc have them right in front/above).
Reply With Quote
Reply

  WebProWorld > Site Design > Graphics & Design Discussion Forum > Accessibility and Usability Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0