Description
In the HTML 4.01 specification contained the following (presumably non-normative) text about controls:
The elements used to create controls generally appear inside a FORM element, but may also appear outside of a FORM element declaration when they are used to build user interfaces.
Since HTML 5 the specification no longer include this or similar text. It could be interpreted the omission meant that authors are now discouraged from doing so, but my read is more likely that it was just lost in the giant rewrite of the spec. In terms of validity, the spec does say the control elements are valid in any parents that accepts phrasing content, so there is that.
While I agree that most use cases of controls on the web do fall into the use case of a logical/semantic form – whether styled as such or not – there are good reasons to use them as user interface elements outside of a form. Some examples:
<button>
s are regularly used for performing actions outside of a form- An
<input type="range">
can be used to control the zoom level in a photo editor/document viewer, or playback/volume control of a media player. - A
<select>
element can be used to switch between different UI modes – such as "slide" vs "outline" vs "table of content", in a presentation app, or to switch between different sources in a file browser/explorer.
Am I correct in understanding that there is no intended change between HTML 4.01 and newer versions in terms of whether the above patterns are considered "appropriate"? Is this something worth clarifying in the spec (by way of adding back a similar sentence that was found in HTML 4.01)? If the patterns are still valid, does the spec have an opinion on what constitutes a <form>
semantically to help determine when (not) to wrap a <form>
around these controls? Are there any accessibility benefits/hazards one way or the other?