views:

63

answers:

2

My last company, which used 4.01 DOCTYPE exclusively, decided to add some new functionality based on use of proprietary tags in the form of

<pp:foo attrOne="something" attrTwo="something else"/>

for certain purposes in their .aspx pages. In the beginning they broke a lot of Javascript until I sussed out that when these proprietary tags were self-closing, they caused (in some cases) the rest of the document to be interpreted as children of that element. (I should add that I didn't feel comfortable using proprietary tags in 4.01 in any case, but that decision was made above my pay grade.)

On the basis of my hunch, I suggested they change this to

<pp:foo attrOne="something" attrTwo="something else"></pp:foo>

and all the broken Javascript DOM manipulations came back right again. I couldn't find any reference to this kind of behavior anywhere, and fixing it was just a lucky guess on my part. My question is, does anyone know specifically why this should be?

+3  A: 

You encountered this problem because HTML 4.01 does not support self-closing tags as in your first example.

Dana Holt
See http://www.w3.org/TR/html4/intro/sgmltut.html 3.2.1 Elements
Pindatjuh
Thanks all. In retrospect this seems obvious, but sometimes from the inside looking out we can't see the forest for the trees.
Robusto
+2  A: 

The W3C html validator gives somewhat of an explanation:

The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document.
For HTML 4.01 Strict, the '/' terminates the tag <FOO (with an implied '>').
However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML.

Dror