Is the rel attribute usage compatible with all browsers and tags

孤者浪人 提交于 2019-12-08 04:54:58

问题


Just to be sure it can be safely used with JQuery scripting.


回答1:


It's part of the HTML 4.01 Specification and should only be used as an attribute of the a and link tag (see the spec). Within a and link tags, it's well supported.




回答2:


According to the HTML 4.01 specification, rel is only valid on a and link elements.

As browsers don't validate documents you can get away with using it on any element you like, but it won't be valid, and it will be semantically meaningless.




回答3:


You'd really need to expand on what you mean by "compatible with all browsers". All browsers will be able to render a document containing rel attributes without barfing, even if they don't explicitly understand what it means. However, if you want to know whether all major browsers would take an explicit action when they encounter a rel attribute, you'd need to specify what situation you're thinking of and what you hope the browsers would do.

As for being compatible with all tags - no, the rel attribute is only appropriate for A and LINK tags in HTML 4 (as per the spec).




回答4:


If you want to store custom data, you're better off using custom attributes. If you prefix them with "data-" then they are valid html5 as well.

See: http://ajaxian.com/archives/embed-your-data-in-html-5



来源:https://stackoverflow.com/questions/1666979/is-the-rel-attribute-usage-compatible-with-all-browsers-and-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!