My website is XHTML 1.1, and I had added ‘rel’ attributes to the <li> and <div> tags on my page, to store data for a jQuery script on the page. When validating my page, I get the error: “there is no attribute ‘rel'”. So, what is the best way to store arbitrary data in HTML tags?
I am working on a comments page for my website. When a comment is entered, it is POSTed via AJAX, which returns JSON of all comments. I then look at the ‘rel’ values to see which comments are already on the page, and only add the new ones.
The jQuery code works fine, it’s just the ‘rel’ attributes don’t validate.
While it’s not XHTML spec, you could use the data-* attributes that are included in HTML5’s spec.
http://html5doctor.com/html5-custom-data-attributes/
If you want to remain fully XHTML 1.1 compliant, you’ll need to create a schema and include its namespace in the
htmlelement, where the schema defines the attributes you want to use, and the elements to which they apply.Extending XHTML