<legend> combination has a visual layout that isn't trivial to recreate with a regular
<div>. I'd like to use this style for some normal content boxes on a site that I'm working on, but all of the documentation that I've found only mentions using
<fieldset> within an html
<form> to contain the inputs. Is it legal/valid to use it outside of this context, or should I just stylize some regular old divs and headings?
edit 1: s/headers/headings/
edit 2: I understand how to do this using divs and headings, but I'm asking why I wouldn't use a fieldset and legend when the code passes validation and the style is exactly what I'm looking for (on a related note, I think "legend" better describes my textual label than "heading"). Most tutorials seem to introduce a fieldset in the context of a form, but in practice, I've often seen this used without a form or inputs, and I haven't seen any official documentation that says that a form is a requirement.
A good answer would probably include a link to official W3C documentation (I couldn't find anything that decisively stated the context in which a fieldset should be used). Alternatively, if you know how a fieldset impacts accessibility or non-standard devices, that would be a good thing to know. Thanks!
Please don't use the 'incorrect' elements purely to get a visual effect.
A div with a border and a relatively positioned (or negative margined) h element with an opaque background will give you the same visual effect with much more meaning and perhaps more importantly, bonus points from the search engines for using headings within your page.
As a general rule of good behaviour and best practice we try to use elements in their intended way for semantic reasons.
You can use headings to make large text on a page, but you don't for the same reasons we stopped using tables for layout.
Fieldset and legend are clearly part of the form specification: http://www.w3.org/TR/html401/interact/forms.html
Using them outside of a form, purely for visual effect, would be akin to using textarea form control to get a border round a box on your page.
I hope you can see where I'm coming from.
Having said all that, there's plenty of support for using them outside of form elements (although not purely for visual effect)
My hard and fast stance of don't is clearly not supported by everyone, so maybe you need to let your conscience decide:
I wouldn't feel comfortable using a fieldset and legend for purely visual reasons, but it seems there's nothing stopping you, and having read that last article, I may just have a complete about face and start using fieldset and legend to group related content outside forms.
p.s. inferring a tone from written content is egocentric. My true intent is to be as helpful as possible with least effort on my part.
A couple of links to support that: http://www.wired.com/science/discoveries/news/2006/02/70179 http://www.catb.org/esr/faqs/smart-questions.html