[VE][65] elements inducing context-sensitive constraints

Error [65]: "document type does not allow element X here; missing one of Y start-tag"

This error message appears in situations like
    <body>
        <a name="top">
Using <a> in this manner is out of date, but it is the simplest example of the issue.

The missing 'Y' list is probably correct, but it is not explanatory. No place, on the W3C Web site nor outside literature, do I recall seeing a statement that the <body> element forces a context-sensitive requirement that all children be block-level elements. This is especially insidious when the error occurs somewhere deep within the code (I tested it as the last child) and it is easy to be oblivious to the fact that you're now back up to the child level.

The explanatory note includes the statement "This might mean that you need a containing element, ...." This is, of course, true, but it fails to note the special character of the <body> element. Anchor elements go so many places that it is hard to conceive that this is inappropriate. The blockquote element has the same undocumented constraint.

The paragraph element has the opposite constraint--it may not include a block-level element. This is a nuisance when I want to include a <pre> within a paragraph.

These context sensitive constraints (and any others) deserve special mention somewhere--within the error message would be most useful; after all, the parser knows the current token--without it the parser couldn't generate the list of possible predecessors.

R. W. Crowl

Received on Monday, 9 September 2013 23:15:34 UTC