Re: [Moderator Action] Suggestion: add some info regarding NOT placing anchor tags between (opening) tr and td tags

Hello Andy,

The HTML specification (and others based on XML) defines a notion of
"valid" content. In the case of a table row, a <tr> element can
include <td> and <th> elements, but no other elements "directly
(cf. [1]). Constraints such as this are expressed in the HTML
specification by what is called a "DTD" (Document Type Definition).

In short, including <a> elements directly under a <tr> element
violates the HTML 4 DTD. We say that such markup is not "valid" (which
has a technical meaning in this context). You have not identified a
"trap" that is specific to <a> elements inside <tr> elements -- you have
simply created an "invalid" html document. There are ways to fix it,
and you won't have to make guesses to do so.

Browsers behave differently. They behave even more differently in how
they handle errors such as this one. Some browsers may try to compensate
for the error by doing something helpful, but since there is no
well-defined behavior for all possible errors, you will inevitably
observe different behavior across browsers in the face of errors.

I recommend that you use the W3C Validation Service to help avoid this
sort of error in the future:
 http://validator.w3.org/

Given the URI of a Web page (or an uploaded file), the service will
point out validation errors which you can then correct. 

Valid markup is not a guarantee of identical behavior across browsers,
but it should greatly increase the likelihood of consistent behavior.

Hope that helps,

 _ Ian

[1] http://www.w3.org/TR/html401/struct/tables.html#edef-TR
On Sat, 2006-01-14 at 03:48 +0000, Andy Williams wrote:
> Hi there, 
> 
> First of all, thanks to your superb site, I am slowly getting to grips
> with creating my first website
> 
> I was having a problem with getting anchors to work having inserted a
> number of <a name="myUniqueName"></a> thingies (where 'myUniqueName'
> really was unique) inbetween (opening) <tr> and <td> tags - and
> clicking the appropriate link in Firefox/Netscape simply moved the
> cusor to the 'first' location (curiously, it worked as I intended in
> both Opera or IE) 
> 
> I went a-Googling and entered your superb site via
> http://www.w3.org/TR/REC-html40/struct/links.html and, slowly, the
> pennies began to drop - so thanks... 
> 
> After reading section 12.2.2 (Nested links are illegal), I had a hunch
> that I should move the  <a name="myUniqueName"></a> thingies (so that
> they came inside <td> ... </td> tags), and it works!  :) 
> 
> However, I am still a bit confused (nothing new there)...
> http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_15161 
> seems to endorse the way I was using those anchors (see their
> subheader <<To make the anchors work in Netscape:>> ) so maybe my
> 'fix' means my HTML is still a long way from being anything like
> 'approved style' ....
> 
> Whatever, this 'trap-for-beginners' doesn't seem to be documented
> anywhere that Google knows about, so, realising you're the bods with
> the most influence, I thought I'd drop you a line 
> 
> Maybe you have a better understanding than I do with regard to my
> waffling  - and maybe you can turn that into some coherent info for
> beginners, like me, who appreciate your site so much 
> 
> Cheers
> Andy Williams 
> NZ
> -- 
> GP: Maybe you are just crazy. 
> M2: Indeed! But do not reject these teaching as false because I am
> crazy. The reason that I am crazy is because they are true.
> http://www.ology.org/principia/body.html
-- 
Ian Jacobs (ij@w3.org)   http://www.w3.org/People/Jacobs
Tel:                     +1 718 260-9447

Received on Saturday, 14 January 2006 04:08:27 UTC