How bad is an invalid attribute?
To start with, if this is not your first visit here, you know I’m all for web standards. But from time to time, I feel that things get exaggerated. There’s a validation frenzy and way too much work, time and focus put into the wrong details.
IT projects are almost always under a tight deadline and compromising is usually a way of web development life. So, my pet peeve is invalid attributes on elements. When I write code, of course I refrain from using them, hence making it valid. But in my case, I work in a lot .NET-based projects and Web Forms and such in it produces invalid code, especially when using a strict HTML or XHTML doctype. Examples can be attributes like language=JavaScript and the name attribute on the form tag. There are ways to take care of this, but they might affect performance, especially for a web site with a lot of visitors.
While these attributes render the page invalid, to me it doesn’t really matter. I regard it as much more important to focus on writing accessible and semantic code, and where the presentation is a 100% controlled from CSS. And, as Peter-Paul Koch writes in Why QuirksMode, there are a lot of cases where using custom attributes whould make the code a lot cleaner and understandable. Having an attribute named “mandatory” on a form element would make a lot more sense that adding a class for it. Especially if the class attribute then weren’t used for any presentational purpose whatsoever, but only for hooking it up with JavaScript.
So, my advice is: Make sure your code is well-formed, but after that, focus on the important parts instead of unsignificant things like an invalid attribute. Then, if you have time, take care of the attribute too.
Related reading
- March to Your Own Standard by Mike Davidson
- Standards-wielding maniacs by Peter Krantz
- How to generate valid XHTML with .NET by yours truly
















