I use some custom attributes in my html, for jquery stuff. I saw there are data-XYZ
attributes in HTML5, but I need to be xhtml 1.0 strict. What other options do I have?
XHTML 1.0 Strict is the XML equivalent to strict HTML 4.01, and includes elements and attributes that have not been marked deprecated in the HTML 4.01 specification. As of November 2015, XHTML 1.0 Strict is the document type used for the homepage of the website of the World Wide Web Consortium.
XHTML 1.0 Strict is the same as HTML 4.01 Strict, but follows XML syntax rules. In particular, it does not allow the use of presentational elements such as center , font or strike . Presentational attributes such as align , bgcolor and background are similarly banned. Furthermore, it does not allow frames or applets.
An XHTML DTD describes the allowed syntax and grammar of XHTML markup. Every XHTML document must start with a DTD declaration and a line of code that declares that you are starting to write XHTML code.
You can use the jQuery MetaData plugin which allows you to write data in the class attribute in JSON format:
<li class="someclass {some: 'data'} anotherclass">...</li>
Then in your jQuery, to get at the data:
var data = $('li.someclass').metadata();
if ( data.some && data.some == 'data' )
alert('It Worked!');
This should meet your requirements of being xhtml 1.0 strict, and also allows you to use a plug-and-play solution :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With