xiven.com stating the blatantly obvious since 2002

Validity of the argument

The HTML 4 spec. says

12.2.2 Nested links are illegal

Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.

So as Kai rightly asks, why does the following XHTML:

<a href="http://cs/"><b>test <a href="http://different/">test 2</a></b></a>

validate, when the following:

<a href="http://cs/">test <a href="http://different/">test 2</a></a>

does not? The same tried in HTML 4 has the expected behaviour of failing to validate both tests.

Surely the above rule applies to all child objects of the A element as well? If so, the validator is broken (not unheard of). If not the spec. is broken (IMHO).

Posted: 2004-04-26 23:23:27 UTC by Xiven | Cross-references (1) | Comments (5)


  • Ian Hickson (2004-04-29 13:43:56 UTC)

    I answered on the list, shortly after he posted:

  • Xiven (Registered) (2004-04-30 00:44:01 UTC)

    Doesn't the fact that the XML DTD doesn't support this constraint strike you as a bit of a flaw?

  • Ian Hickson (2004-05-01 20:18:37 UTC)

    Not particularly. There are many things SGML DTDs can't do either.

    For example, how would you say, in an SGML or XML DTD, that the <foo> element can have a "bar" attribute OR contain content, but not both? You can't. How about saying that an element can contain zero or one FOO elements and one or more BAR elements, in any order? I don't think you can do that either.

    Also, DTDs can't say much about the contents of attributes. For example <a href="" type="bla"> is invalid ("bla" is not a MIME type) but there is no way to say that in a DTD, so a document containing that would validate, despite being non-conformant.

    Validation is not the last word in conformance. There are plenty of things that not even a turing-complete schema language could check for conformance, at least not without some significant steps forward in AI! :-)

  • Xiven (Registered) (2004-05-01 21:36:57 UTC)


  • mahesh (2004-07-17 19:43:26 UTC)

    80% of the DTDS I find don't work right.