E
E
Ekaterina Sava2015-02-03 17:59:55
HTML
Ekaterina Sava, 2015-02-03 17:59:55

Is it valid/logical/semantic to use section inside a form?

Actually, the topic is actually the whole point of the issue.
But I'll try to describe it in more detail:

  • the page contains 3 groups of inputs (first comes the group with text inputs, then the group with the radio, the last one with checkboxes)
  • each group has its own title
  • I wanted to use initially such things as <fieldset>, <legend>but something stops me ... they are somehow old and dusty. In vain?
  • I have the whole page on such new (well, okay, not so new) and brilliant HTML5 tags and I really want to "shove" inside <section>, it seems beautiful and logical. Dissuade?

That is, I want a structure like this:
<form>
    <section>
        <h2>Title</h2>
        <label for="name">Name</label>
        <input id="name" type="text">
    </section>
</form>

And yes, of course I googled it. Everywhere only about the reverse history <form>inside <section>- this is understandable just right.
PS And yes, the question is not about validity by W3C, do not send me to the validator page, it did not give me an answer to my question.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GreatRash, 2015-02-03
@EkaterinaSava

The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content. Each section should be identified, typically by including a heading (h1-h6 element) as a child of the section element.

According to the W3C , you can in principle use section for your purposes. However, under the definition there is a note suggesting that if you want to use section for purely presentational purposes, it is recommended to use a regular div.
For example, people from Mozilla also see nothing wrong with shoving section inside the form. Moreover, they recommend doing this (although they do not refuse fieldset either).
In the section about forms in the spec , comrades from the consortium even shove tables into the form, and there is nothing wrong with that either.
So wrap in what you see fit safely. If only it carried a semantic load, and did not perform a purely design function.

I
IceJOKER, 2015-02-03
@IceJOKER

<fieldset>и <legend>Why are they old? where did you get this from? - www.tutorialspoint.com/html5/html5_deprecated_tags.htm - here are the old elements for you.
I can’t even imagine what kind of document structure you have O_O
but about the question - who is stopping you from inserting a piece of code into the validator and checking it?
Valid, but it's more logical to put the form in the section
67e6859ccf.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question