开发者

How can I use HTML5 Data Attributes in XHTML?

Does anyone know how开发者_C百科 the HTML5 data attributes (data-*) can be implemented in XHTML without rendering the markup as invalid?

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


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

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.

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.


I don't know if this is a general solution, but it worked for me:

<ul data-clearing="">

Ie. just append ="" to make it a valid XML attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜