如何在XHTML中使用HTML5数据属性? [英] How can I use HTML5 Data Attributes in XHTML?

查看:157
本文介绍了如何在XHTML中使用HTML5数据属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何在不将标记视为无效的情况下在XHTML中实现HTML5数据属性( data - * )?

Does anyone know how the HTML5 data attributes (data-*) can be implemented in XHTML without rendering the markup as invalid?

是否存在允许在现有HTML元素上使用的自定义命名空间黑客?

Is there a custom namespacing hack that would allow this on existing HTML elements?

推荐答案

您可以使用< a href =http://www.w3.org/TR/html5/introduction.html#html-vs-xhtml\"rel =noreferrer> XHTML5 。然后你的标记将是XML,并且是有效的XHTML5。

You could use XHTML5. Then your mark-up would be XML, and valid XHTML5.

认为你也可以使用XML命名空间在XHTML1上使用它们 - 我我不太熟悉XML,所以我不确定。

I think you could also use XML namespacing to use them on XHTML1 — I’m not very familiar with XML, so I’m not sure.

我认为这两种方法技术上都要求你提供服务页面为XML(而不是 text / html ),Internet Explorer不支持。但我怀疑他们在浏览器中工作得很好,即使你没有。

I think that both of these methods technically require you to serve your pages as XML (instead of text/html), which Internet Explorer doesn’t support. But I suspect they’d work just fine in browsers even if you didn’t.

这篇关于如何在XHTML中使用HTML5数据属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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