简体   繁体   中英

“Proprietary” HTML tags in HTML 4.01

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?

您遇到了此问题,因为HTML 4.01不像您的第一个示例那样支持自动关闭标签。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM