How can I use HTML5 data attributes in XHTML?

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

Is there a custom name gown that will allow this on existing HTML elements?

+6
xml html5 validation xhtml custom-data-attribute
source share
2 answers

You can use XHTML5 . Then your premium will be XML and valid XHTML5.

I think you could also use the XML namespace to use them on XHTML1. I am not very familiar with XML, so I'm not sure.

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

+6
source share

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

 <ul data-clearing=""> 

Those. just add ="" to make it a valid XML attribute.

-one
source share

All Articles