SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <label> for <textarea>?

    Is it a good idea to add a label for a textarea or not?

  2. #2
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Why wouldn't it be?

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your reply

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2004
    Location
    Minneapolis, MN
    Posts
    1,924
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be fine, as long as you remember that you have to give the textare an id over a name. Otherwise the label doesn't properly correspond with the textarea.

  5. #5
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but if you give it an id, can you give it a class`?
    like:
    Code:
    class="bigtextarea"

  6. #6
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Yep.

  7. #7
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so both id and class attributes are ok in the same tag? But id is required right?

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need the ID attribute on the TEXTAREA, because that's what is referenced from the FOR attribute of the LABEL. You need a NAME attribute on the TEXTAREA (in most browsers) if you want its value to be passed to the receiving script on submit. Then you may add a CLASS attribute if you want or need one.

    HTML Code:
    <label for="my-text">My Label</label>
    <textarea id="my-text" name="mytext" class="my-class" rows="4" cols="30"></textarea>
    Birnam wood is come to Dunsinane

  9. #9
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can skip both ID and FOR if you wrap the LABEL around the textarea, but keep in mind that IE wont put the cursor in the textarea when you click the label if you don't have the FOR attribute.
    HTML Code:
    <label>My label <textarea ...></textarea></label>
    Simon Pieters

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WCAG 1.0 checkpoint 12.4 (priority 2):
    Associate labels explicitly with their controls.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •