Forum Moderators: open
Obviously I am not allowed to use forms in XHTML - here we have the progress! I'm loving it!
<div id="form"><p>
<form id="form1" method="post" action="http://whatever.com/actions?id=whatever"><label>Name:<br /><input type="text" name="Name" size="20" /></label>
<label>Email:<br /><input type="text" name="email" size="20" /></label>
<label>Your Message (required):<br /><textarea cols="20" rows="50" name="message"></textarea></label>
<input type="submit" value="Send Comment" /><input type="reset" value="Clear" />
<!-- tracker -->
<input type="hidden" name="tracker" value="whatever" />
</form></p></div>
I would be very grateful for any help!
when trying to validate XHTML you have to follow them to the letter
the <p> element needs to go as Blobfisk says, because you can't nest block elements inside a <p> element [w3.org]
<!ELEMENT P - O (%inline;)* -- paragraph -->
your <form> is a block level element, so it can't go in the <p>
then to the form element [w3.org]
<!ELEMENT FORM - - (%block;¦SCRIPT)+ -(FORM) -- interactive form -->
(%block;¦SCRIPT)+ = can only contain one or more block level elements or script elements (in any order)
-(FORM) = must not include another <form> element
so it can't directly contain the inputs and labels as they are not block level elements
so you need to nest a block level element inside the Form element, one which can contain your inline elements, you could simply use a div inside the form, or fieldset [w3.org]might be a better choice, as it id design to contain form elements it's definition:
<!ELEMENT FIELDSET - - (#PCDATA,LEGEND,(%flow;)*) -- form control group -->
Fieldset, start tag required, end tag required
(#PCDATA,LEGEND,(%flow;)*) = can contain text, entities, the legend element and flow element, zero or more times..
flow elements are either block or inline level elements
so your nesting would look something like
<div>
<form>
<fieldset>
<label><input>
</fieldset>
</form>
</div>
or you could replace the fieldset with another div instead..
<div id="form">
<form id="form1" method="post" action="http://example.com/actions?id=whatever">
<fieldset>
<label>Name:<br /><input type="text" name="Name" size="20" /></label>
<label>Email:<br /><input type="text" name="email" size="20" /></label>
<label>Your Message (required):<br /><textarea cols="20" rows="50" name="message"></textarea></label>
<input type="submit" value="Send Comment" /><input type="reset" value="Clear" />
<!-- tracker -->
<input type="hidden" name="tracker" value="whatever" />
</fieldset>
</form></div>
Edit: beat me to it, Suzy! (with a much better response too)
[edited by: Receptional_Andy at 12:35 pm (utc) on July 10, 2008]