如果您在HTML标签中使用自定义属性会发生什么? [英] What happens if you use custom attribute in a HTML tag?

查看:173
本文介绍了如果您在HTML标签中使用自定义属性会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与 jQuery 本身无关,但我发现了一个名为元数据的插件那里,其中一个示例使用自定义标记属性:< li data = {some:'random',json:'data'}> ...< / li>



跨浏览器?这会在验证标记时失败吗?

谢谢。

浏览器不会在乎,因为很少有浏览器实际验证HTML。如果您尝试将它视为XHTML,它将会失败,因为它不是有效的XHTML。


this question isn't related to jQuery itself but I found a plugin named Metadata found there and one of the example uses custom tag attribute: <li data="{some:'random', json: 'data'}">...</li>.

Q: Is that cross-browser? Will this fail when validating markup?

Thanks.

解决方案

The browser won't care, since very, very few browsers actually validate the HTML. It will fail if you try to treat it as XHTML though, since it isn't valid XHTML.

这篇关于如果您在HTML标签中使用自定义属性会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆