I'm hoping somebody can provide some insight on a couple of little quirks about HTML 4.01 that I don't quite get.
I've been making sites that validate as HTML 4.01 Strict for a few years, and every page on all the sites would validate except for pages that contain forms. The validator would say that "input" tags of various kinds aren't allowed to appear in the context that they're in. For instance with this kind of code:
Today after seeing a failed validation again on a page containing forms, I finally googled for how HTML 4.01 forms are supposed to work, and found a simplified example on W3C's site that went like this:
So I wrapped the contents of my form between a <p> and </p>. Now the validator stopped complaining about my input fields, but now it complained that it found a </p> that wasn't matched to anything.
So, the main thing here that I don't get about HTML 4.01 is: why don't <p> tags need to be closed? I removed the </p> and then it validated fine. I've always used <p> as like a drop-in replacement for "<br><br>" and never closed them. I read somewhere that if you include a block-level element such as <div> inside of a <p>..</p>, that it implicitly closes the <p> tag and that the following </p> will cause the validation to fail.
Why does <p> work this way?
-------------
Cuvou.com | My personal homepage
I've been making sites that validate as HTML 4.01 Strict for a few years, and every page on all the sites would validate except for pages that contain forms. The validator would say that "input" tags of various kinds aren't allowed to appear in the context that they're in. For instance with this kind of code:
Code:
<form name="comment" action="/" method="post">
<input type="hidden" name="p" value="blog.comment">
<input type="hidden" name="action" value="save">
<input type="hidden" name="id" value="35">
<strong>Name:</strong><br>
<input type="text" name="name" size="20"><p>
<strong>Message:</strong><br>
<textarea cols="30" rows="6" name="message"></textarea><p>
<input type="submit" value="Post Comment">
<div style="display: none">
Do not edit these fields.<br>
<input type="text" size="20" name="email" value=""><br>
<input type="text" size="20" name="url" value="[URL unfurl="true"]http://"><br>[/URL]
<textarea cols="20" rows="2" name="comment"></textarea>
</div>
</form>
Today after seeing a failed validation again on a page containing forms, I finally googled for how HTML 4.01 forms are supposed to work, and found a simplified example on W3C's site that went like this:
Code:
<FORM action="[URL unfurl="true"]http://somesite.com/prog/adduser"[/URL] method="post">
<P>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" id="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" id="lastname"><BR>
<LABEL for="email">email: </LABEL>
<INPUT type="text" id="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</P>
</FORM>
So I wrapped the contents of my form between a <p> and </p>. Now the validator stopped complaining about my input fields, but now it complained that it found a </p> that wasn't matched to anything.
So, the main thing here that I don't get about HTML 4.01 is: why don't <p> tags need to be closed? I removed the </p> and then it validated fine. I've always used <p> as like a drop-in replacement for "<br><br>" and never closed them. I read somewhere that if you include a block-level element such as <div> inside of a <p>..</p>, that it implicitly closes the <p> tag and that the following </p> will cause the validation to fail.
Why does <p> work this way?
-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'