On couple of sites I've used
instead ofCode:<fieldset> <form... > ... </form> </fieldset>
Should I change the code and appropriate css? Is this a huge mistake or a minor one?Code:<form...> <fieldset> ... </fieldset> </form>
| SitePoint Sponsor |
On couple of sites I've used
instead ofCode:<fieldset> <form... > ... </form> </fieldset>
Should I change the code and appropriate css? Is this a huge mistake or a minor one?Code:<form...> <fieldset> ... </fieldset> </form>


I think you should change the markup, because it's clearly wrong. If nothing else, what if a newbie looks at your markup and believes this is the right way to do it? You may be cause irreparable harm to some innocent beginner out there.![]()
Birnam wood is come to Dunsinane
It's also invalid, because a fieldset has to start with a legend.
Simon Pieters

haha just imagine that!!! his friends will tell him what's that? that's weird!! and he would say: ''you don't know Jack.... I saw that on SitePointOriginally Posted by AutisticCuckoo
!!''
![]()
I actually saw this on some other site. I liked the efect with 1px border and 1px padding on fieldset and then pale blue background color and 10px padding on form tag. Anyway, the code (XHTML 1.0 Transitional) validates quite well with w3c and cynthia. I know it looks stupid, though
You can achieve the exact same effect with the fieldset inside the form.
Simon Pieters
Of course, I know that. I guess my question could be: why is more semantically correct to put form in some redundant div like thisOriginally Posted by zcorpan
then what I did. Now, I will change it, but I'd like to know the theoretical reason why is so wrong. I mean, all the form controls are inside fieldset, and that's the purpose of the fieldset tag.Code:<div class="formcontainer"><form...>...</form></div>
Why do you need the div?
As for theoretical reasons: the fieldset is intended to group related form controls, thus it makes sense to have the form control grouping element inside the form controls' form. What if you want another group of related form controls in the same form?
Simon Pieters
As Simon says, just add your class or ID to the form itself and style that to look how you want.Originally Posted by zcorpan
Thanks everyone. I still can't understand how I managed to make such a huge mistake. Just another silly question, because I'm lacking confidence right now: Is this semantically correct?whereCode:<form...> <fieldset> <legend class="hide">Contact</legend> .... </fieldset> </form>Code:.hide {display: none;}
Yes, although the class name is presentational, and display:none isn't the best hiding method if you want screen readers to read the legend. It's better to position it off-screen somehow.
Simon Pieters
Bookmarks