8 replies [Last post]
Verschwindende
Verschwindende's picture
Offline
Guru
Last seen: 5 weeks 4 days ago
Timezone: GMT-4
Joined: 2009-10-09
Posts: 2050
Points: 2282

I've been using implicit form labels just because it's easier to style but according to this page explicit form labels is preferred and implicit is deprecated. I had no idea (I wonder what else I'm behind on).

So, it does mention explicit:

<label for="name">Name: </label>
<input id="name" name="name" tabindex="1" />

and implicit:
<label>Name: <input id="name" name="name" tabindex="1" /></label>
but what about both?
<label for="name">Name: <input id="name" name="name" tabindex="1" /></label>

In the last example the label is both implicit and explicit. Is there a word to describe that?

So, since strictly implicit labels are deprecated what about the last example since it does include the explicit for attribute?

Tags:
gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 year 17 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

As one who automatically

As one who automatically makes the explicit connection, I've not seen the problem, and I see no reason for the two connectives not to live together in harmony. Smile As I see it, though, the issue is not with the implicit connection, but with the assistive technologies' failing to take advantage of the connection. Where html5 is trying to pave every cow path in sight, here we have a broad freeway going directly to the destination, and wcag wants to jackhammer it. Silly Stupid.

The implicit connection offers a tremendous lift when using DOM scripting, as the label is the parent of the form control. If the implicit nesting is not used, it is much more complex, for example, to tie error messages to the label, for one thing that comes easily to mind.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Verschwindende
Verschwindende's picture
Offline
Guru
Last seen: 5 weeks 4 days ago
Timezone: GMT-4
Joined: 2009-10-09
Posts: 2050
Points: 2282

gary.turner wrote: ... The

gary.turner wrote:

... The implicit connection offers a tremendous lift when using DOM scripting, as the label is the parent of the form control. If the implicit nesting is not used, it is much more complex, for example, to tie error messages to the label, for one thing that comes easily to mind. ...

Yes, that's another good reason to use the implicit. I do prefer the implicit labels and have mostly shunned declaring them explicitly just because I believe adding <asp:label> to every input field is just unnecessary overhead when a plain html <label> will do.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 25 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Never really understood the

Never really understood the whys and wherefores of this aspect of labeling form controls. Definitely from a styling point of view implicit labels for radios and checkboxes are far easier to style than strangely disconnected labels.

This statement sort of irritates me:

="WCAG on implicit labels" wrote:

In practice this is not supported by user agents and should not be used.

Yes it is Puzzled That is a sweeping statement and inaccurate!

However it ought to be stressed that IE < 7? definitely 6 do not support implicit linking and one needs to use the 'for' attribute as well but I always have and apart from adding a little weight to the page don't think it does any harm.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 35 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

http://green-beast.com/blog/?

http://green-beast.com/blog/?p=254 (the bug)

Though there was originally mention of it on one of the wcag1 pages... and I still haven't found an answer, if this has been fixed in newer versions of W-E. 5 is pretty old.

I'm no expert, but I fake one on teh Internets

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 25 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

I was waiting for that to be

Big smile I was waiting for that to be mentioned. It's a sightly different issue though although in the same vein as IE not making the implicit association.

It feels so very wrong to write off whole bits of acceptable code because an application has utterly ballsed things up, but that is somewhat the nature of this game we play *sigh*

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 35 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

Found another one, though

Found another one, though only something to be aware of; how often does one put an image in a label? But if you do...
IE8 doesn't transfer focus to the input.

I'm no expert, but I fake one on teh Internets

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 25 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

However the alt text is

However the alt text is linked, just hope that they wouldn't really use this text though Smile
" alt="Image download support must be enabled"

What I note with slight horror and am minded of Opera here is the number of 'Regression bugs' bugs not present in IE7 but I assume are in IE6? So is MS copying Operas behaviour of days gone by where they re-introduced bugs that had been cleared up in previous version

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 35 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

They didn't all ring a bell

They didn't all ring a bell as being IE6 bugs, so, not sure.

Not like FF doesn't add in bugs too. Remember FF 2.0.0.8 where negative margin float tricks (Holy Grail style) pages all died horrid deaths? Somehow that bugger got into the trunk! But at least they covered their ears from the screams and fixed it in 2.0.0.10 : )

I'm no expert, but I fake one on teh Internets