Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2006
    Thanked 2 Times in 2 Posts

    How do you structure your forms?

    I have read too much literature that repetitively reiterates (ha) the need to separate structure from behavior and style . . . and "more importantly" to use proper HTML syntax for marking up your content.

    So my question would be this, is there some standard markup you are all using for your form elements? When I began I was using <div class="input"> and <div class="label"> before each label/input element in the form . . . now, I'm just using labels and input tags but this makes it hard to place an error message during validation.

    I read one book that said maybe we shouldn't use paragraph elements in forms since they aren't necessarily the proper element. What do you use?

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Essex, UK
    Thanked 0 Times in 0 Posts
    Well a div isn't a bad choice as it doesn't really have much of a meaning... a span would also be acceptable but as it's by default an inline element, the div would be best if you wanted a block element.

    You could use line breaks as in the following example but it depends on how much extra markup you wish to use (wrapping each form element in a div) and how much you want to make it 'semantic' I guess.



    Posting Permissions

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