开发者

Should we use fieldset even for one search box input?

Should we use fieldset even for one search box input? Wh开发者_JAVA技巧ich 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜