SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should I put <h2> inside <form>?

    Is it ok to put elements like <h2> inside <form> tags? I want the form to have a heading and would also like to give some margins in general to the whole form. I could therefore set an id to the form and apply the margins to that id. Else to exclude the <h2> from the form I would create a generic div just outside the form, and apply margins to that, and therefore also put the h2 outside the <form>. Which is best?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,195
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Both are fine, so far as I know. You can certainly put elements like h2 inside the form element. But another option is to use a fieldset within the form, and make the title with the <legend> element. Here's more info: http://reference.sitepoint.com/html/fieldset

    Worth knowing about the option, anyway.

  3. #3
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I would not put any non-form elements inside a form. I would use the generic wrapping div.

    One reason is that many of the more popular screen readers have a Forms Mode. Some go automatically into Forms Mode (which lets you fill in the form) and there only form controls are read out. That means headers, instructions, and questions who are not inside labels or legends are missed. I would not count on people first listening through in regular mode to hear instructions and then go back and go to Forms Mode to fill it in... we're lazy, we don't want to read something twice.

    I put all my headers and instructions outside forms, with the exception of help text (which, if it's inside a label, can be found by a reader in Forms Mode). I have one huge monster form that unfortunately has headers inside, but to compensate I added titles to the inputs (previous version of the form used headers as Main Questions). But ideally it would be totally rewritten.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,195
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    One reason is that many of the more popular screen readers have a Forms Mode. Some go automatically into Forms Mode (which lets you fill in the form) and there only form controls are read out. That means headers, instructions, and questions who are not inside labels or legends are missed.
    Wow, good point. I SO need to get on with learning more about accessibility.

  5. #5
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Read Gez Lemon's bloggitty and grab a copy of the JAWS demo (40 minutes) for Winblows and play around.
    I still haven't gotten NVDA/Win (a free reader) even though I should. Each reader's like a browser: has its own quirks.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,195
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Thanks, will do. I got a book recently, but haven't delved very far in yet. Keep getting unstracted.

  7. #7
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    What book?

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,195
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    What book?
    I'm afraid to say, as you'll probably tell me I've wasted my money:

    Accessibility Shortcuts: Tricks for Circumventing WCAG 2.0


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
  •