1

Should we use <label> for every input? , even for submit button and keep hidden thorough css if we don't want to show label.

or no need of label for submit button?

.hide {display:none}

<fieldset>
  <legend>Search</legend>
    <label for="Search">Search...</label>
      <input value="" id="Search" name="Search">
    <label for="Submit" class="hide">Submit</label>
      <input type="submit" value="Go!" name="submit" id="submit">
</fieldset>

or we should use like this (no label for submit)

<fieldset>
  <legend>Search</legend>
    <label for="Search">Search...</label>
      <input value="" id="Search" name="Search">
      <input type="submit" value="Go!" name="submit" >
</fieldset>
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • possible duplicate of [Should we put inside – Sarfraz May 24 '10 at 13:19
  • 1
    @Jitendra: You are asking similar QUESTION with little modification. Since you are a questioner here on SO, don't ask a similar QUESTIONS to save the database of SO :) – Sarfraz May 24 '10 at 13:19
  • 1
    Yup, has asked 673 questions with only 96 answers although no one is restricted to that. –  May 24 '10 at 13:23
  • 1
    @Web Logic: Agreed there is no restriction he can ask as many as he want :) – Sarfraz May 24 '10 at 13:23
  • @Sarfraz Ahmed - What you found duplicate? tell me? one is about to use ` – Jitendra Vyas May 24 '10 at 15:14
  • 1
    @Jitendra: you said "*for me both are different question.*" but for me it is not, it is **basically ** the same question. – Sarfraz May 24 '10 at 20:36

2 Answers2

2

No. Don't use labels for elements which have intrinsic label text (e.g. all kinds of buttons). (Note: Faking a label with the value attribute doesn't count).

See the description section of the WCAG section on the subject.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

From the official documentation:

The LABEL element may be used to attach information to controls. Each LABEL element is associated with exactly one form control.

http://www.w3.org/TR/html4/interact/forms.html#edef-LABEL

Note that the term is "may be," not "must be." However, it is always a good idea to use a label because this turns out to be handy for accessibility reasons and for browsers running on touchscreen devices.

Community
  • 1
  • 1
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • 3
    Actually, this answers your question perfectly. – Barrie Reader May 24 '10 at 09:33
  • 2
    @metal-gear-solid if it doesn't answer your question, perhaps you could provide a little more information why not??? – Christian Payne May 24 '10 at 09:41
  • @Neurofluxation, @Christian Payne - if there was any problem in given info in the question then how David Dorward gave very well and accurate answer. – Jitendra Vyas May 24 '10 at 15:16
  • @Sarfraz - you are right "it is always a good idea to use a `label`, this turns out to be handy" but not for every input. it's mentioned in a link provided in David Dorward's answer. my question not should we use ` – Jitendra Vyas May 24 '10 at 15:20
  • 1
    @Jitendra: i answered your question: "*Should we use – Sarfraz May 24 '10 at 20:33