Should we use fieldset even for one search box input?
Asked Answered
C

4

5

Should we use fieldset even for one search box input? Which we use in header of the site usually?

Cloutman answered 30/4, 2010 at 12:15 Comment(0)
R
7

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.

Regimentals answered 30/4, 2010 at 12:43 Comment(3)
Dorward - but i saw today on webstandards.org they are marking up searchbox like this <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
One organization doing something doesn't automatically make it useful to do so.Regimentals
While it's true that there is no obligation to use 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
D
2

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.

Dimidiate answered 30/4, 2010 at 12:38 Comment(0)
Q
0

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.

Quirites answered 30/4, 2010 at 12:23 Comment(0)
N
-2

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! ;)

Nanice answered 18/3, 2011 at 3:9 Comment(2)
Standards are the single thing the web is built on. If people started making HTML tags instead of DIVs, how would you ever read the page? Tags have a name with a meaning for a reason. Also, read some DTD's.Costplus
The biggest reason I can think of not to use structural elements for design purposes is that it interferes with accessibility. Assistive technologies like screen readers rely on structural elements to interpret the page so they can relay the relevant information to users with disabilities. If structural elements are used decoratively (e.g., an <h1> used just to make a text element look bold), screen reader users won't be able to tell what the page's structure is supposed to be.Spectral

© 2022 - 2024 — McMap. All rights reserved.