namespaced-attributes-considered-harmful
namespaced attributes considered harmful
Namespaced attributes are undesirable for numerous reasons.
because they are
invalid
Random namespaced attributes are invalid.
There is no standard (W3C or other) that shows how to validate namespaced attributes.
There is no validation service (e.g. like http://validator.w3.org ) that validates namespaced attributes, probably because it is undefined how to validate them.
In fact, there is no spec for how to validate multiple-namespaced documents at all. W3C never solved this problem.
unstylable
Just go ahead and try to get even one browser to handle CSS style rules based on some random namespaced attribute. Now try to get two browsers to do so.
There simply isn't browser support (nor even W3C Recommendations for that matter) for how to use namespaced attributes to style content.
invisible
Data in namespaced attributes (most attributes for that matter) is invisible to the user and thus undesirable. Perhaps this is worthy of pointing to another write-up: invisible-data-considered-harmful.
If you are using namespaced attributes for data "not for user consumption", i.e. not for human data but rather for purely programmatic data, just use JSON, don't even bother with markup, XML or otherwise.
ugly
namespaced attributes are ugly to read and write. more typing and punctuation. enough said.
misconceptions
just needs to be XHTML
Some have asserted that if you simply put namespaced attributes in proper "XHTML", e.g. sent as
text/xml-xhtml
[sic] then they will work fine.
- There is no content-type
text/xml-xhtml
- Lack of browser support for
application/xhtml+xml
means it is unusable from a practical standpoint. - XHTML does not provide a validation model for namespaced attributes that are defined outside of XHTML.