So what if custom HTML attributes aren’t valid XHTML?

The ramification is that w3c comes along in 2, 5, 10 years and creates an attribute with the same name. Now your page is broken.

HTML5 is going to provide a data attribute type for legal custom attributes (like data-myattr=”foo”) so maybe you could start using that now and be reasonably safe from future name collisions.

Finally, you may be overlooking that custom logic is the rational behind the class attribute. Although it is generally thought of as a style attribute it is in reality a legal way to set custom meta-properties on an element. Unfortunately you are basically limited to boolean properties which is why HTML5 is adding the data prefix.

BTW, by “basically boolean” I mean in principle. In reality there is nothing to stop you using a seperator in your class name to define custom values as well as attributes.

class="document docId.56 permissions.RW"

Leave a Comment