Let say you had a form for ...whatever. For example a poll.. whose title is important enough to be a header... "Whatcha doing for Xmas?" and some radio buttons and submit. Would you put the Hx tag inside the form tag or outside ? I would like to know what is considered best practice: <hx> </hx> <form></form> or <form><hx> </hx> </form>.
I would follow the same concept as how the <fieldset> element works personally, you have the legend then the form which makes it clear and easy to understand.
so the does the fieldset represent the form tag ( the hx is within the form)?? or the Hx outside "then the form"? sorry I was kinda lost in your semantics.. no pun.
I was just referencing the <fieldset> element as a reference for the <legend> tag, basically in a semantic sense both of the examples below should yield the same SEO ouput since they are representing the content afterwards.
The advantage of the Legend element (within a fieldset) is that the text is then explicitly associated with the form, too. But the code should be like this:
... other form elements ...
Well my conundrum comes from the fact That in some cases I could already have fieldsets with legends.. or that the content may seem headline like.... Although for a poll question I can see how it would fit semantically to use LEGEND.
I suppose the feel I am getting thus far is that if a header must be involved it is best to put it outside the form tag.
I put EVERYTHING that is not a form control outside the form. Every time (well, not counting when I've been told to add "help text", which I then either stuff inside a form control or use ARIA to associate it). Users with a UA that has a "Forms Mode" will be getting only form controls inside the form, except ARIA-associated stuff.
I put the header outside (and above), I put the instructions outside (above! I hate when the instructions are at the bottom, I don't see that until after I've already filled everything in), and legend-text (like "fields marked with * are required").
*edit by "legend-text" I mean like a map legend, not the <legend> element
Only on simple, dedicated form pages would I consider letting the (lone) legend do that work (often if it's redundant I'll just hide the legend rather than not have a header).
In this specific case the heading would typically belong outside of the form since you are introducing the form.
Yeah, makes sense. I was torn because I saw an opportunity to streamline the css and utilize an already existing container. BUT at the same time felt exactly the same way as what Mallory expressed. So I decided to do what any good leader would do and ask what everyone else was doing
Haha, and as I come back to this thread, I'm currently battling a long, complicated single form who happens to have craploads of plain text inside it. It's sort of an output-like content, but the <output> tag is not correct for this case.
Now going to have to break my head trying to figure out how to present all this content inside a form (basically people are adding and changing bits of text; their set text is displayed later, and there's descriptions of what these types of text are... and there simply aren't correct form controls for this text. #doomed
This topic is now closed. New replies are no longer allowed.