Should we use fieldset
even for one search box input
? Which we use in header of the site usually?
No. There is no point in using fieldset elements unless you are dividing the form up into logical sets of fields.
It is excellent for (for example) marking up a set of fields for delivery address and some nearly identical ones for billing address. If you can't make sets (plural) don't use a fieldset element.
fieldset
for just one input, there's also no obligation not to. fieldset
's content model is remarkably flexible, and the W3 working draft includes an example where nested fieldsets contain only one input each (plus disabled/enabled radios in the legends, but those are treated as part of the parent). Is it a desirable pattern that should be followed? Not really. Is it a harmful pattern that should not be followed? Also, not really. –
Alodium I think fieldset's aim is to split your form into semantic parts. If your field is the only one of its semantic part, then you should use a fieldset, as it add semantic.
What you shouldn't do, is to use fieldset for design purpose.
To my mind, it's not necessary unless you want some sort of frame container or parent-child type styling or grouping on the page.
Why shouldn't he use it for design purposes? What's the big deal? Personally, I think fieldset has a very unique look that is difficult to achieve without tricky css and/or javascript. And it can look really nice in minimalist forms. I mean, this is really simple and pretty:
<fieldset style="width:200px;">
<legend>Live Search:</legend>
<input style="width:100%; border:2px solid #BADA55;" id="q"/>
</fieldset>
People always poo poo using structural elements for design, but who made that rule? Function as form is a common theme in design (think doors repurposed as coffee tables or a rocking chair made out of wagon wheels). Why should it be any different in code? Don't let standards stand in your way, dude! ;)
© 2022 - 2024 — McMap. All rights reserved.
<form action="/index.php" method="get" id="fm-search"> <fieldset> <legend>Search</legend> <label for="s"><span>Search WaSP</span> <input value="" class="search" name="s" id="s"></label> <input type="submit" value="Go!" name="submit" class="submit"> </fieldset> </form>
– Cloutman