Forum Moderators: phranque

Message Too Old, No Replies

Validation Results

W3.org results concerning TR not allowed here

         

Alternative Future

2:06 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello all,

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>

The site is dynamic and built with templates and tiles I have to use the forms (many to a page) at the most convenient place for both the template/tile and requirements.

TIA,

-George

rocknbil

3:48 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is incorrectly nested.


<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>

Alternative Future

7:33 am on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks rocknbil,

Would it also be possible to do:


<table>
<tr>
<td>
<form>
<table>
<tr>
<td>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

I am in a way forced to keep my forms inside some of the HTML elements due to the design of my template. The first table declaration is outside the JSP/html containing the form i.e. it is in the master layout template JSP/html which calls on many JSP/html tiles/pages.

-George

rocknbil

3:12 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could, and it might even function, but it will still never validate. In addition to the nesting problem there is now a td and a tr preceding the opening form tag that don't close.

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.