joeellis
joeellis

Reputation: 2785

XHTML Transitional rel attribute alternative

I'm trying to add some custom data within a tag to reference later in a jQuery call, and I usually use "rel=" for something like this. However, I'm working in an XHTML Transitional document, and it gives me a "there is no rel attribute".

Are there any alternate attributes I can use to attach custom data to an HTML tag while still keeping the document valid?

Upvotes: 1

Views: 974

Answers (1)

Francisc
Francisc

Reputation: 80485

If you care much about XHTML validity in the case you mentioned, a common practice is to use the class attribute and space different things there.

HTML5 allows this via the data attribute or rather prefixing your own custom attributes with data-, e.g. data-my-var="hello". But this is invalid in XHTML.

Upvotes: 3

Related Questions