views:

38

answers:

2

Does anyone know how 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?

A: 

It can't be done. XHTML is a precursor of HTML5.

In the same way that CSS3 properties will never validate in a CSS2 validator, you cannot validate HTML5 according to XHTML.

Stargazer712
For XHTML 1.0 and 1.1, true. For XHTML5, not true.
Paul D. Waite
I was unaware that there was such a thing. Good to know :)
Stargazer712
+2  A: 

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.

Paul D. Waite