Forum Moderators: phranque
Taking my site through the validator @ w3.org I am getting repeated errors regarding the TR element not allowed at this position. I have managed to see where the problem might be and would like someone to confirm this with me and perhaps suggest a fix. Anyway below is the header of my HTML document no errors are reported here but it will let you see what DOCTYPE I am using and that I am in full compliance mode.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<meta name="description" content="Short description to site..."/>
<meta name="keywords" content="key1 key2 key3..."/>
<title>Site Title</title>
<link href="/unsecure/css/styles.css" rel="stylesheet" type="text/css">
</head>
The error at w3.org is document type does not allow element "TR" here I have many of these within a starting <table> but after the starting <table> I have a starting form <form> then the TR's so this might be where the actual problem lies? that the form is not encapsulated in proper HTML tags? If this is the case then where is it appropriate to place the starting <form> tag.
At present we have
<body>
<table>
<tr>
<td>
<table>
<form>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</form>
</table>
</td>
</tr>
</table>
</body>
TIA,
-George
<table>
<form>
<tr><td>a</td></tr>
<tr><td>b</td></tr>
<tr><td>c</td></tr>
</form>
</table>
This is correct.
<form>
<table>
<tr><td>a</td></tr>
<tr><td>b</td></tr>
<tr><td>c</td></tr>
</table>
</form>
When it says no TR's allowed here, it' probably means within the form.
I've seen this before, as a hack to remove extra space after a form. A form will always create extra space after it in every browser, creating havok in designing around them, and this method prevents the space, apparently still works, but will never validate.
I figured out you can do the same thing with CSS and keep it properly nested:
<style>
form.nospace { padding-top:0; padding-bottom:0; margin-top:0; margin-bottom:0; }
</style>
<form class="nospace">
<table>
<tr><td>a</td></tr>
<tr><td>b</td></tr>
<tr><td>c</td></tr>
</table>
</form>
Would it also be possible to do:
<table>
<tr>
<td>
<form>
<table>
<tr>
<td>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
-George
Nothing follows the table tag except tr or th, and nothing goes between tr and td except white space. Your form tags must go completely outside the table tags or completely inside the td tags to validate.
If you play around with the css, you may be able to get the form to work without blowing up the template.