|validating to strict with textarea|
| 7:31 am on Apr 15, 2010 (gmt 0)|
I had a problem last night that has suprised me, either that or I have not noticed it before:-
<input type="submit" name="submit" value="submit">
I thought as this would be perfectly fine going though the validator, but it turns out as it needs nesting :-
<p><input type="submit" name="submit" value="submit"></p>
Or is this just the difference between transitional & strict?
This may seem trivial, but I thought that having the entire form encased in 1 div would be ok, but adding the <p> tags around each element made it validate properly.
Maybee I have missed a day at html school somwhere along the line ;-p but it just caught me out for half hour last night.
| 10:48 am on Apr 15, 2010 (gmt 0)|
There are some bonkers rules in strict, so I don't bother with it most of the time (except when I'm writing example code).
If you use a <div> within the <form> to contain all elements, it should be ok. This will avoid applying unwanted CSS rules for <p> to the <textarea>. I think I did this a while back for some bit of code somewhere but I'm not certain.
| 12:30 pm on Apr 15, 2010 (gmt 0)|
Hi there Kaled,
Yes, with respect to using a single div to "hold" a form,I thought as I would be Ok. There is no discernable difference having the <p> tags there or not, at least I cant see it. I suppose that this gives you the option of dressing up the elements aesthetics at a later date.
| 2:59 pm on Apr 15, 2010 (gmt 0)|
As defined in the HTML 4.01 Spec. [w3.org], the form element can only contain block elements (like div and p) or script element.
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
Therefore, it's usually best to do something like this:
You can still have a "formcontainer" div around the form as well if you want, but it might make more sense to just make the inner div element the "formcontainer" (assuming you're styling that element in some way).
| 4:05 pm on Apr 15, 2010 (gmt 0)|
I thought that's what I said, but not as clearly I guess!
| 4:22 pm on Apr 15, 2010 (gmt 0)|
Yes, you did. I just wanted to clarify that this was not something new or specific to the strict DTD, and provide the details of "why". :)
| 8:20 pm on Apr 15, 2010 (gmt 0)|
Thanks for the explanations, Kaled, you had explained perfectly, more than likely human error on my part! I since re-read the thread, and when I looked over the my code, I realised that I hadn't placed a div on the inside of the form, hence why I was surprised when placed a generic p tag in there and the strict validator came back as Ok. I had only placed one on the outside, the container in essence.
I have since placed an internal Div, instead of the p tags and everything is Ok.
I have only recently started to use strict, as I thought I was already coding to that standard within the context of transitional. I am too which is good news, just something as trivial as that caught me out ;-p
Again, thanks for the advice & links,