Grow your CSS skills. Land your dream job.

HTML5 Proper Structure – Form Tag

  • # November 14, 2012 at 9:25 am

    Hello All!

    With HTML5, we are encouraged to use <article>, <section>, <header>, etc tags in place of the <div> tags when appropriate. Would it be semantically correct to use the <form> tag in the same manner for a form in a webpage and style it as I would one of the above elements?

    Example:


    VS


    To me, it seems logical to use it the first method above. After all, that section of content is a form and adding a <section> or <div> container seems like code bloat. Thanks in advance.

    # November 14, 2012 at 9:32 am

    ‘Form’ itself does nothing so, in essence it’s exactly the same as a div or section.

    Here’s what HTML5 Doctor says:

    > The form element represents a collection of form-associated elements, some of which can represent editable values that can be submitted to a server for processing.

    So in answer to your question…yes, it would be semantically correct to use the ‘form’ element as a wrapper without needing to wrap it in another element.

    # November 14, 2012 at 9:34 am

    Thank you for the quick and well referenced response, Paulie_D. Much appreciated.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".