<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: How bad is an invalid attribute?</title>
	<atom:link href="http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/</link>
	<description>Web development and Internet trends</description>
	<pubDate>Sat, 11 Oct 2008 06:38:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Jim</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1364</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Wed, 19 Oct 2005 09:42:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1364</guid>
		<description>Frode,

That's a good example, but form validation is often best handled by looking at the form as a whole - i.e. whether a field is valid or not is often dependent upon other fields.  As such, finding hacks for fitting in validation for individual fields isn't as useful as it would first seem.

Probably the best solution would be to generate both the client-side Javascript and server-side validation from XForms on the server, but I have yet to find time to investigate that possibility.

Right now, I don't think unobtrusive form validation is possible, at least not without having to supplement it with extra Javascript half the time.  I really don't see the point in having a script like that, if it isn't going to do the job properly, you might as well write the Javascript by hand, it only takes a minute.

As far as misusing valid attributes, you're right, I don't condone that, in fact I think it's much more harmful than using custom attributes.</description>
		<content:encoded><![CDATA[<p>Frode,</p>
<p>That&#8217;s a good example, but form validation is often best handled by looking at the form as a whole - i.e. whether a field is valid or not is often dependent upon other fields.  As such, finding hacks for fitting in validation for individual fields isn&#8217;t as useful as it would first seem.</p>
<p>Probably the best solution would be to generate both the client-side Javascript and server-side validation from XForms on the server, but I have yet to find time to investigate that possibility.</p>
<p>Right now, I don&#8217;t think unobtrusive form validation is possible, at least not without having to supplement it with extra Javascript half the time.  I really don&#8217;t see the point in having a script like that, if it isn&#8217;t going to do the job properly, you might as well write the Javascript by hand, it only takes a minute.</p>
<p>As far as misusing valid attributes, you&#8217;re right, I don&#8217;t condone that, in fact I think it&#8217;s much more harmful than using custom attributes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrys</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1288</link>
		<dc:creator>Patrys</dc:creator>
		<pubDate>Thu, 13 Oct 2005 10:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1288</guid>
		<description>Dave M:

This happens on IE 5.5 and earlier. Unfortunately, these still have more that 10% of the market here in Poland.

IE6 seems to fix this issue.</description>
		<content:encoded><![CDATA[<p>Dave M:</p>
<p>This happens on <acronym title="Internet Explorer">IE</acronym> 5.5 and earlier. Unfortunately, these still have more that 10% of the market here in Poland.</p>
<p>IE6 seems to fix this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frode Danielsen</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1285</link>
		<dc:creator>Frode Danielsen</dc:creator>
		<pubDate>Wed, 12 Oct 2005 21:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1285</guid>
		<description>Jim,

A simple example I'd like a suggestion from you which makes semantic meaning as well for: minlength in a form text field.

Another one concerning forms could be an attribute for connecting two fields (i.e. two password fields, to check they are equal to eachother), although I guess you'll suggest the rel attribute for this, or applying a numbering scheme to the id value (i.e. password1, password2) and then using regexp or similar to hook up the connections.

Although probably not the _worst_ attribute to lack, it's a simple example where I can't think of any other attribute conveying the same semantic meaning. You could of course just do with checking for non-zero length and within maxlength or use a specific regexp-format checker.

Maybe I'm trying to argue that there's just barely a thin line between using an invalid attribute, and misusing a valid attribute semantically ;-) But then I don't think you are advocating misusing attributes, at least I hope you don't.</description>
		<content:encoded><![CDATA[<p>Jim,</p>
<p>A simple example I&#8217;d like a suggestion from you which makes semantic meaning as well for: minlength in a form text field.</p>
<p>Another one concerning forms could be an attribute for connecting two fields (i.e. two password fields, to check they are equal to eachother), although I guess you&#8217;ll suggest the rel attribute for this, or applying a numbering scheme to the id value (i.e. password1, password2) and then using regexp or similar to hook up the connections.</p>
<p>Although probably not the _worst_ attribute to lack, it&#8217;s a simple example where I can&#8217;t think of any other attribute conveying the same semantic meaning. You could of course just do with checking for non-zero length and within maxlength or use a specific regexp-format checker.</p>
<p>Maybe I&#8217;m trying to argue that there&#8217;s just barely a thin line between using an invalid attribute, and misusing a valid attribute semantically <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> But then I don&#8217;t think you are advocating misusing attributes, at least I hope you don&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1278</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Wed, 12 Oct 2005 14:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1278</guid>
		<description>Jens,

&lt;blockquote&gt;
	On the other hand, if this problem is induced by certain tools, then oneâ€™s using the wrong tools. Yah, simple, but itâ€™s just true.
&lt;/blockquote&gt;

Well, yes... :-)
But a) I'm not the one choosing the tools, and b) if the tools do a good job otherwise, I think a deprecated attribute is a minor problem.

Jim,

&lt;blockquote&gt;
	 you arenâ€™t limited to the class attribute, you can use other attributes and element types - meta, cite, rel, rev, all sorts.
&lt;/blockquote&gt;

True, although it sounds like they can be a bit misused then; like a &lt;code&gt;rel&lt;/code&gt; attribute containing a &lt;acronym title="Globally Unique Identifier"&gt;GUID&lt;/acronym&gt; and such.

&lt;blockquote&gt;
	As far as deprecated attributes goes, Iâ€™d say that if you canâ€™t get rid of them, use a Transitional doctype - unless you run into doctype switching issues of course.
&lt;/blockquote&gt;

I agree, but then you have the risk with the Almost Standards Mode rendering in Mozilla, which might affect the presentation of certain elements.

&lt;blockquote&gt;
	As for performance, Iâ€™d say benchmark with the correct code and only allow the deprecated stuff through if you have performance problems.
&lt;/blockquote&gt;

Definitely the best approach, but hard to motivate the time for doing it and the people that needs to be involved, to the manager/-s responsible, if the only errors are a couple of invalid attributes.</description>
		<content:encoded><![CDATA[<p>Jens,</p>
<blockquote><p>
	On the other hand, if this problem is induced by certain tools, then oneâ€™s using the wrong tools. Yah, simple, but itâ€™s just true.
</p></blockquote>
<p>Well, yes&#8230; <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
But a) I&#8217;m not the one choosing the tools, and b) if the tools do a good job otherwise, I think a deprecated attribute is a minor problem.</p>
<p>Jim,</p>
<blockquote><p>
	 you arenâ€™t limited to the class attribute, you can use other attributes and element types - meta, cite, rel, rev, all sorts.
</p></blockquote>
<p>True, although it sounds like they can be a bit misused then; like a <code>rel</code> attribute containing a <acronym title="Globally Unique Identifier">GUID</acronym> and such.</p>
<blockquote><p>
	As far as deprecated attributes goes, Iâ€™d say that if you canâ€™t get rid of them, use a Transitional doctype - unless you run into doctype switching issues of course.
</p></blockquote>
<p>I agree, but then you have the risk with the Almost Standards Mode rendering in Mozilla, which might affect the presentation of certain elements.</p>
<blockquote><p>
	As for performance, Iâ€™d say benchmark with the correct code and only allow the deprecated stuff through if you have performance problems.
</p></blockquote>
<p>Definitely the best approach, but hard to motivate the time for doing it and the people that needs to be involved, to the manager/-s responsible, if the only errors are a couple of invalid attributes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1276</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Wed, 12 Oct 2005 13:55:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1276</guid>
		<description>I agree with Robert, Frode has a point - that custom attributes allow you to assign arbitrary values to arbitrary properties without using a hack with the class attribute or similar.

Perhaps I'm atypical, but I've *never* found a case where this is actually necessary.  Every instance I can think of where somebody has wanted to do this, there's always been a valid way of doing it without it being a hack - you aren't limited to the class attribute, you can use other attributes and element types - meta, cite, rel, rev, all sorts.  I think people forget about these because browsers don't have any built-in behaviour for many of them.

There is one decent reason for using custom attributes, and that's when it's the only way of getting a certain effect in a browser.  In particular, Internet Explorer drives me nuts because they could easily have allowed a meta element or similar to do the things that they want, but instead forced people to use invalid code.

To nitpick, I don't think it's sensible to talk about whether a DOM tree is *valid*, because validity is something that encompasses syntax, which isn't expressed in a DOM tree.  However, it does make sense to talk about whether it conforms to the specifications, and using custom attributes means your DOM tree is non-conformant.

As far as deprecated attributes goes, I'd say that if you can't get rid of them, use a Transitional doctype - unless you run into doctype switching issues of course.

As for performance, I'd say benchmark with the correct code and only allow the deprecated stuff through if you have performance problems.  Sure, you might have wasted your time in a few instances, but in the most common case, you'll have ended up with a better product.  If there's performance problems down the line, you can always disable the extra code.

Dave,

I definitely remember older versions of Internet Explorer having problems with multiple classes - try Internet Explorer 4 (Win) or 5.2 (Mac).  I'm not sure when they fixed it.</description>
		<content:encoded><![CDATA[<p>I agree with Robert, Frode has a point - that custom attributes allow you to assign arbitrary values to arbitrary properties without using a hack with the class attribute or similar.</p>
<p>Perhaps I&#8217;m atypical, but I&#8217;ve *never* found a case where this is actually necessary.  Every instance I can think of where somebody has wanted to do this, there&#8217;s always been a valid way of doing it without it being a hack - you aren&#8217;t limited to the class attribute, you can use other attributes and element types - meta, cite, rel, rev, all sorts.  I think people forget about these because browsers don&#8217;t have any built-in behaviour for many of them.</p>
<p>There is one decent reason for using custom attributes, and that&#8217;s when it&#8217;s the only way of getting a certain effect in a browser.  In particular, Internet Explorer drives me nuts because they could easily have allowed a meta element or similar to do the things that they want, but instead forced people to use invalid code.</p>
<p>To nitpick, I don&#8217;t think it&#8217;s sensible to talk about whether a <acronym title="Document Object Model">DOM</acronym> tree is *valid*, because validity is something that encompasses syntax, which isn&#8217;t expressed in a <acronym title="Document Object Model">DOM</acronym> tree.  However, it does make sense to talk about whether it conforms to the specifications, and using custom attributes means your <acronym title="Document Object Model">DOM</acronym> tree is non-conformant.</p>
<p>As far as deprecated attributes goes, I&#8217;d say that if you can&#8217;t get rid of them, use a Transitional doctype - unless you run into doctype switching issues of course.</p>
<p>As for performance, I&#8217;d say benchmark with the correct code and only allow the deprecated stuff through if you have performance problems.  Sure, you might have wasted your time in a few instances, but in the most common case, you&#8217;ll have ended up with a better product.  If there&#8217;s performance problems down the line, you can always disable the extra code.</p>
<p>Dave,</p>
<p>I definitely remember older versions of Internet Explorer having problems with multiple classes - try Internet Explorer 4 (Win) or 5.2 (Mac).  I&#8217;m not sure when they fixed it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave M</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1273</link>
		<dc:creator>Dave M</dc:creator>
		<pubDate>Wed, 12 Oct 2005 13:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1273</guid>
		<description>Patrys:

I tried recreating the scenario you describe with IE/Win(6.0) applying styles that begin with those names. I couldn't recreate that.. do you have more evidence of that happening, or is it with other IE/Win versions?</description>
		<content:encoded><![CDATA[<p>Patrys:</p>
<p>I tried recreating the scenario you describe with <acronym title="Internet Explorer">IE</acronym>/Win(6.0) applying styles that begin with those names. I couldn&#8217;t recreate that.. do you have more evidence of that happening, or is it with other <acronym title="Internet Explorer">IE</acronym>/Win versions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Meiert</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1272</link>
		<dc:creator>Jens Meiert</dc:creator>
		<pubDate>Wed, 12 Oct 2005 09:03:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1272</guid>
		<description>Two thoughts:

On the one hand, if one strives for absolute standards compliance, there is no question whether to use invalid attributes (or elements) or not, even within certain time constraints. (The only time I had this problem was when considering &lt;abbr&gt;sIFR&lt;/abbr&gt; for image replacement - but the "sifr" attribute made it a definite no-go, unfortunately.)

On the other hand, if this problem is induced by certain tools, then one's using the wrong tools. Yah, simple, but it's just true.</description>
		<content:encoded><![CDATA[<p>Two thoughts:</p>
<p>On the one hand, if one strives for absolute standards compliance, there is no question whether to use invalid attributes (or elements) or not, even within certain time constraints. (The only time I had this problem was when considering <abbr>sIFR</abbr> for image replacement - but the &#8220;sifr&#8221; attribute made it a definite no-go, unfortunately.)</p>
<p>On the other hand, if this problem is induced by certain tools, then one&#8217;s using the wrong tools. Yah, simple, but it&#8217;s just true.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrys</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1271</link>
		<dc:creator>Patrys</dc:creator>
		<pubDate>Wed, 12 Oct 2005 08:57:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1271</guid>
		<description>Actually, &lt;code&gt;class&lt;/code&gt; attribute can accept any number of space-separated names. This works equally fine for both &lt;abbr title="Cascading Style Sheets"&gt;CSS&lt;/abbr&gt; and &lt;abbr title="JavaScript"&gt;JS&lt;/abbr&gt;. Well, with one exception, if you do something like &lt;code&gt;class="foo bar"&lt;/code&gt;, Internet Explorer for Windows will apply all styles with classes that &lt;em&gt;begin with&lt;/em&gt; both foo and bar instead of performing a exact string match. Thus &lt;code&gt;.fooBaz&lt;/code&gt; will also get applied. Simply, if you use multiple classes for one element try to keep your class names unique in terms of common prefixes.</description>
		<content:encoded><![CDATA[<p>Actually, <code>class</code> attribute can accept any number of space-separated names. This works equally fine for both <abbr title="Cascading Style Sheets"><acronym title="Cascading Style Sheets">CSS</acronym></abbr> and <abbr title="JavaScript">JS</abbr>. Well, with one exception, if you do something like <code>class="foo bar"</code>, Internet Explorer for Windows will apply all styles with classes that <em>begin with</em> both foo and bar instead of performing a exact string match. Thus <code>.fooBaz</code> will also get applied. Simply, if you use multiple classes for one element try to keep your class names unique in terms of common prefixes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1270</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Wed, 12 Oct 2005 08:17:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1270</guid>
		<description>Thanks everyone for sharing your opinion!

There are two parallel tracks here, so let me address them separately:

Track one: I do not in any way promote invalid attributes when hand-coding (or Dreamweavering, for those of you who swing that way). In my code I always use correct attributes for correct elements. What I was going for was that &lt;em&gt;deprecated&lt;/em&gt; attributes which are automatically generated by your environment (for instance, by .NET) will not affect the rendering in web browsers, thus they end up last on my priority list since they won't break the web site in question. As I state in my post, if time is given I take care of them too.

Another question I wanted to raise with this was that when there are ways to fix the automatically produced incorrect output through string parsing and such, but there's a risk it might affect performance (at least for high-traffic web sites), what should you choose? With major .NET projects, I'm personally afraid of getting a lesser performance of the web site just to satisfy my own need to remove a few invalid &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;language&lt;/code&gt; attributes. If you then have a customer that demands code that validates, you present these options to them and it's their call. It's all about prioritizing.

Track two: This is about using custom attributes for JavaScript hook-up. I had an interesting discussion with Jeroen Mulder off-site and he also pointed me to his post &lt;a href="http://jeroenmulder.com/weblog/2005/03/class_id_are_not_presentation.php" rel="nofollow"&gt;Class and ID are not presentation-centered&lt;/a&gt;, and I also read &lt;a href="http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1264" rel="nofollow"&gt;Jim's&lt;/a&gt; and other people's comments thoroughly.

Humbly, I'll back down on this. Using the &lt;code&gt;class&lt;/code&gt; attribute isn't &lt;em&gt;only&lt;/em&gt; for attaching &lt;acronym title="Cascading Style Sheets"&gt;CSS&lt;/acronym&gt; and it's definitely applicable to use the &lt;code&gt;class&lt;/code&gt; attribute for something else like this: &lt;code&gt;class="required"&lt;/code&gt;. But Frode is on to something: in very advanced web applications, sometimes a single attribute isn't sufficient and one doesn't want to do string parsing of different hyphen-separated values in the &lt;code&gt;class&lt;/code&gt; attribute value.

Dustin,

My take is that if you don't accept invalid attributes in the &lt;acronym&gt;HTML&lt;/acronym&gt; code, you shouldn't do it through &lt;acronym title="Document Object Model"&gt;DOM&lt;/acronym&gt; either.</description>
		<content:encoded><![CDATA[<p>Thanks everyone for sharing your opinion!</p>
<p>There are two parallel tracks here, so let me address them separately:</p>
<p>Track one: I do not in any way promote invalid attributes when hand-coding (or Dreamweavering, for those of you who swing that way). In my code I always use correct attributes for correct elements. What I was going for was that <em>deprecated</em> attributes which are automatically generated by your environment (for instance, by .NET) will not affect the rendering in web browsers, thus they end up last on my priority list since they won&#8217;t break the web site in question. As I state in my post, if time is given I take care of them too.</p>
<p>Another question I wanted to raise with this was that when there are ways to fix the automatically produced incorrect output through string parsing and such, but there&#8217;s a risk it might affect performance (at least for high-traffic web sites), what should you choose? With major .NET projects, I&#8217;m personally afraid of getting a lesser performance of the web site just to satisfy my own need to remove a few invalid <code>name</code> and <code>language</code> attributes. If you then have a customer that demands code that validates, you present these options to them and it&#8217;s their call. It&#8217;s all about prioritizing.</p>
<p>Track two: This is about using custom attributes for JavaScript hook-up. I had an interesting discussion with Jeroen Mulder off-site and he also pointed me to his post <a href="http://jeroenmulder.com/weblog/2005/03/class_id_are_not_presentation.php" rel="nofollow">Class and ID are not presentation-centered</a>, and I also read <a href="http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1264" rel="nofollow">Jim&#8217;s</a> and other people&#8217;s comments thoroughly.</p>
<p>Humbly, I&#8217;ll back down on this. Using the <code>class</code> attribute isn&#8217;t <em>only</em> for attaching <acronym title="Cascading Style Sheets"></acronym><acronym title="Cascading Style Sheets">CSS</acronym> and it&#8217;s definitely applicable to use the <code>class</code> attribute for something else like this: <code>class="required"</code>. But Frode is on to something: in very advanced web applications, sometimes a single attribute isn&#8217;t sufficient and one doesn&#8217;t want to do string parsing of different hyphen-separated values in the <code>class</code> attribute value.</p>
<p>Dustin,</p>
<p>My take is that if you don&#8217;t accept invalid attributes in the <acronym></acronym><acronym title="HyperText Markup Language">HTML</acronym> code, you shouldn&#8217;t do it through <acronym title="Document Object Model"></acronym><acronym title="Document Object Model">DOM</acronym> either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frode Danielsen</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1269</link>
		<dc:creator>Frode Danielsen</dc:creator>
		<pubDate>Tue, 11 Oct 2005 22:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1269</guid>
		<description>One part of my answer is at &lt;a href="http://www.456bereastreet.com/archive/200510/are_invalid_attributes_valid/" title="Are invalid attributes valid?" rel="nofollow"&gt;Roger Johansson's follow-up&lt;/a&gt;.

Yes, the class-attribute is quite semantic and functional for hooking up behavioral Javascript - and you could even make the analogy of it being similar to implementing Interfaces in OOP. But attributes have a purpose of giving a value to some property of the element, and how would you go about doing this with class-names? Create your own class-name-format, using a hyphen to separate property from value (i.e. class="equalTo-anotherElement")?

I'm not completely against using invalid attributes, but I mostly see uses for it in more advanced web-applications. Adding class-names for describing behaviour/functionality of an element through Javascript is really fine, and makes sense to me, and it facilitates even more unobtrusiveness in the script.

Btw, everyone interested in using class-names for adding behaviour should look into &lt;a href="http://simon.incutio.com/archive/2003/03/25/getElementByClassName" title="getElementsByClassName" rel="nofollow"&gt;Simon Willison's original getElementsByClassName&lt;/a&gt; or it's improved versions. And maybe &lt;a href="http://bennolan.com/behaviour/" title="Behaviour" rel="nofollow"&gt;Ben Nolan's Behaviour&lt;/a&gt; as well..</description>
		<content:encoded><![CDATA[<p>One part of my answer is at <a href="http://www.456bereastreet.com/archive/200510/are_invalid_attributes_valid/" title="Are invalid attributes valid?" rel="nofollow">Roger Johansson&#8217;s follow-up</a>.</p>
<p>Yes, the class-attribute is quite semantic and functional for hooking up behavioral Javascript - and you could even make the analogy of it being similar to implementing Interfaces in OOP. But attributes have a purpose of giving a value to some property of the element, and how would you go about doing this with class-names? Create your own class-name-format, using a hyphen to separate property from value (i.e. class=&#8221;equalTo-anotherElement&#8221;)?</p>
<p>I&#8217;m not completely against using invalid attributes, but I mostly see uses for it in more advanced web-applications. Adding class-names for describing behaviour/functionality of an element through Javascript is really fine, and makes sense to me, and it facilitates even more unobtrusiveness in the script.</p>
<p><acronym title="By The Way">BTW</acronym>, everyone interested in using class-names for adding behaviour should look into <a href="http://simon.incutio.com/archive/2003/03/25/getElementByClassName" title="getElementsByClassName" rel="nofollow">Simon Willison&#8217;s original getElementsByClassName</a> or it&#8217;s improved versions. And maybe <a href="http://bennolan.com/behaviour/" title="Behaviour" rel="nofollow">Ben Nolan&#8217;s Behaviour</a> as well..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dustin Diaz</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1268</link>
		<dc:creator>Dustin Diaz</dc:creator>
		<pubDate>Tue, 11 Oct 2005 21:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1268</guid>
		<description>I think it's invalid if it's deliberately inserted by hand, but there is a clear exception made when they are put in thru dom scripting. The DOM memory may show that it's invalid, but as far as the original source and validator is concerned, your document remains completely valid.</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s invalid if it&#8217;s deliberately inserted by hand, but there is a clear exception made when they are put in thru <acronym title="Document Object Model">DOM</acronym> scripting. The <acronym title="Document Object Model">DOM</acronym> memory may show that it&#8217;s invalid, but as far as the original source and validator is concerned, your document remains completely valid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Snook</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1267</link>
		<dc:creator>Jonathan Snook</dc:creator>
		<pubDate>Tue, 11 Oct 2005 19:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1267</guid>
		<description>If your intention is to set attributes for hooking into the behavioural layer, why not just describe any of these attributes at the behavioural level.

You could create a form description class that takes a form ID as part of the constructor. 

But alas, I'm just being pedantic. Tying into the class attribute works just fine, too. :)</description>
		<content:encoded><![CDATA[<p>If your intention is to set attributes for hooking into the behavioural layer, why not just describe any of these attributes at the behavioural level.</p>
<p>You could create a form description class that takes a form ID as part of the constructor. </p>
<p>But alas, I&#8217;m just being pedantic. Tying into the class attribute works just fine, too. <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Williams</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1266</link>
		<dc:creator>Steve Williams</dc:creator>
		<pubDate>Tue, 11 Oct 2005 18:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1266</guid>
		<description>Perhaps I could stand on the shoulders of giants and graciously ask what full-blown CMS *is* recommended for valid, tableless, semantic code when you're free to choose?

I've been searching for an open source CMS that fits those requirements for some time, but have so far struck a blank.</description>
		<content:encoded><![CDATA[<p>Perhaps I could stand on the shoulders of giants and graciously ask what full-blown <acronym title="Content Management System">CMS</acronym> *is* recommended for valid, tableless, semantic code when you&#8217;re free to choose?</p>
<p>I&#8217;ve been searching for an open source <acronym title="Content Management System">CMS</acronym> that fits those requirements for some time, but have so far struck a blank.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Johansson</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1265</link>
		<dc:creator>Roger Johansson</dc:creator>
		<pubDate>Tue, 11 Oct 2005 15:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1265</guid>
		<description>I agree with Jim here: the &lt;code&gt;class&lt;/code&gt; attribute is &lt;strong&gt;not&lt;/strong&gt; just for CSS. It's perfectly fine to use it to add hooks for a script.

On the invalid attribute issue I get your point, but I disagree ;-). As Jim already said: how will you quickly and easily tell when you have a "real" error? And if you have clients that specifically request that their sites validate, how are you going to teach them to distinguish a harmless validation error from a catastrophic one?

Sure, put fixing that .Net stuff at the bottom of your list. But do fix it.</description>
		<content:encoded><![CDATA[<p>I agree with Jim here: the <code>class</code> attribute is <strong>not</strong> just for <acronym title="Cascading Style Sheets">CSS</acronym>. It&#8217;s perfectly fine to use it to add hooks for a script.</p>
<p>On the invalid attribute issue I get your point, but I disagree ;-). As Jim already said: how will you quickly and easily tell when you have a &#8220;real&#8221; error? And if you have clients that specifically request that their sites validate, how are you going to teach them to distinguish a harmless validation error from a catastrophic one?</p>
<p>Sure, put fixing that .Net stuff at the bottom of your list. But do fix it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1264</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Tue, 11 Oct 2005 14:19:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1264</guid>
		<description>Robert,

I strongly disagree with your feeling that class is just for CSS.  It's never been true, the only loud voice that pushes that misconception is ppk, and I think his overenthusiasm for his technique is clouding his judgement in that respect.

The HTML specification itself states that class is, among other things, suitable for general purpose processing:

&lt;blockquote cite="http://www.w3.org/TR/REC-html40/struct/global.html#adef-class"&gt;
The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML:

* As a style sheet selector (when an author wishes to assign style information to a set of elements).
* For general purpose processing by user agents.
&lt;/blockquote&gt;

&lt;blockquote cite="http://www.w3.org/TR/REC-html40/appendix/changes.html#h-A.3.2"&gt;The id and class attribute allow authors to assign name and class information to elements for style sheets, as anchors, for scripting, for object declarations, general purpose document processing, etc.&lt;/blockquote&gt;

I can appreciate that if you have only ever used class for stylesheets before, the use of them for scripting can appear to be a bit of a hack, but that's simply not the case.  The class attribute has *always* been bigger than mere styling.  It's just that, until recently, the Javascript community has been dominated by scripters who are unaware of the W3C and choose to invent their own ways of doing things instead of using existing attributes in the manner in which they are intended.  CSS, on the other hand, has always had a strong contingent of W3C-aware developers and is more reliant upon the class attribute.</description>
		<content:encoded><![CDATA[<p>Robert,</p>
<p>I strongly disagree with your feeling that class is just for <acronym title="Cascading Style Sheets">CSS</acronym>.  It&#8217;s never been true, the only loud voice that pushes that misconception is ppk, and I think his overenthusiasm for his technique is clouding his judgement in that respect.</p>
<p>The <acronym title="HyperText Markup Language">HTML</acronym> specification itself states that class is, among other things, suitable for general purpose processing:</p>
<blockquote cite="http://www.w3.org/TR/REC-html40/struct/global.html#adef-class"><p>
The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML:</p>
<p>* As a style sheet selector (when an author wishes to assign style information to a set of elements).<br />
* For general purpose processing by user agents.
</p></blockquote>
<blockquote cite="http://www.w3.org/TR/REC-html40/appendix/changes.html#h-A.3.2"><p>The id and class attribute allow authors to assign name and class information to elements for style sheets, as anchors, for scripting, for object declarations, general purpose document processing, etc.</p></blockquote>
<p>I can appreciate that if you have only ever used class for stylesheets before, the use of them for scripting can appear to be a bit of a hack, but that&#8217;s simply not the case.  The class attribute has *always* been bigger than mere styling.  It&#8217;s just that, until recently, the Javascript community has been dominated by scripters who are unaware of the <acronym title="World Wide Web Consortium">W3C</acronym> and choose to invent their own ways of doing things instead of using existing attributes in the manner in which they are intended.  <acronym title="Cascading Style Sheets">CSS</acronym>, on the other hand, has always had a strong contingent of <acronym title="World Wide Web Consortium">W3C</acronym>-aware developers and is more reliant upon the class attribute.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1263</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Tue, 11 Oct 2005 12:28:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1263</guid>
		<description>Jens,

Thank you for those!
After looking at them, I remember seeing one of them a while ago.

Also, when it comes to the customer, they would never accept that their web site doesn't validate in the W3C validator just because I used a custom &lt;acronym title="Document Type Definition"&gt;DTD&lt;/acronym&gt; for some attributes.</description>
		<content:encoded><![CDATA[<p>Jens,</p>
<p>Thank you for those!<br />
After looking at them, I remember seeing one of them a while ago.</p>
<p>Also, when it comes to the customer, they would never accept that their web site doesn&#8217;t validate in the <acronym title="World Wide Web Consortium">W3C</acronym> validator just because I used a custom <acronym title="Document Type Definition"></acronym><acronym title="Document Type Definition">DTD</acronym> for some attributes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Wedin</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1262</link>
		<dc:creator>Jens Wedin</dc:creator>
		<pubDate>Tue, 11 Oct 2005 12:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1262</guid>
		<description>Have you read the articles over at ALA about custom DTD's? Quite interesting.

http://www.alistapart.com/articles/customdtd
http://www.alistapart.com/articles/customdtds2</description>
		<content:encoded><![CDATA[<p>Have you read the articles over at ALA about custom <acronym title="Document Type Definition">DTD</acronym>&#8217;s? Quite interesting.</p>
<p><a href="http://www.alistapart.com/articles/customdtd" rel="nofollow">http://www.alistapart.com/articles/customdtd</a><br />
<a href="http://www.alistapart.com/articles/customdtds2" rel="nofollow">http://www.alistapart.com/articles/customdtds2</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1261</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Tue, 11 Oct 2005 12:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1261</guid>
		<description>Tommy,

I was mainly going for old deprecated attributes when describing them as not important. They should be safe to have there anyway.

Jeroen and Tommy,

In my opinion, using a &lt;code&gt;class&lt;/code&gt; attribute that doesn't have any corresponding rule in the &lt;acronym title="Cascading Style Sheets"&gt;CSS&lt;/acronym&gt; feels like an incorrect approach, although I share Tommy's fear about using a custom attribute name that then might show up in a future specification. Personally, I therefore don't use custom attributes but I wish there really were some that could be used for JavaScript-only hook-ups.

Marco,

I agree with every word you wrote.

Kalle,

I have to use the saying "get a project to harbor" more often! :-)

If it's written in an agreement that it has to validate, it's a totally different question.

And I haven't tried the validator with a custom &lt;acronym title="Document Type Definition"&gt;DTD&lt;/acronym&gt;.

Jim,

I do promote writing valid code, and as you state, it's really helps less experienced web developers if it's all valid instead of trying to guess which errors are "ok" and which aren't.

When it comes to custom attributes, see my answer above to Tommy and Jeroen.</description>
		<content:encoded><![CDATA[<p>Tommy,</p>
<p>I was mainly going for old deprecated attributes when describing them as not important. They should be safe to have there anyway.</p>
<p>Jeroen and Tommy,</p>
<p>In my opinion, using a <code>class</code> attribute that doesn&#8217;t have any corresponding rule in the <acronym title="Cascading Style Sheets"></acronym><acronym title="Cascading Style Sheets">CSS</acronym> feels like an incorrect approach, although I share Tommy&#8217;s fear about using a custom attribute name that then might show up in a future specification. Personally, I therefore don&#8217;t use custom attributes but I wish there really were some that could be used for JavaScript-only hook-ups.</p>
<p>Marco,</p>
<p>I agree with every word you wrote.</p>
<p>Kalle,</p>
<p>I have to use the saying &#8220;get a project to harbor&#8221; more often! <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If it&#8217;s written in an agreement that it has to validate, it&#8217;s a totally different question.</p>
<p>And I haven&#8217;t tried the validator with a custom <acronym title="Document Type Definition"></acronym><acronym title="Document Type Definition">DTD</acronym>.</p>
<p>Jim,</p>
<p>I do promote writing valid code, and as you state, it&#8217;s really helps less experienced web developers if it&#8217;s all valid instead of trying to guess which errors are &#8220;ok&#8221; and which aren&#8217;t.</p>
<p>When it comes to custom attributes, see my answer above to Tommy and Jeroen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1260</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Tue, 11 Oct 2005 11:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1260</guid>
		<description>Okay, so when you are validating, and your error count goes from 123 (all "okay" errors) to 124 (123 "okay" errors and one "proper" error), are you going to notice?

How about if you went from completely valid and zero errors to invalid and one error?  Will you notice then?

What about when your new junior hire starts making mistakes?  Is he qualified to know when some errors are okay and others aren't?  Are you going to spot his mistakes even if he doesn't?

When there's no way to do what you want and also conform to the specification, I understand deviating from spec.  But there's really no need for inventing new attributes.  Sure, you might be able to cut a few corners here and there, but you are only shifting that extra work into QA.  Obviously the people who don't do any QA won't notice and tout the "savings", but it's really just false economy.</description>
		<content:encoded><![CDATA[<p>Okay, so when you are validating, and your error count goes from 123 (all &#8220;okay&#8221; errors) to 124 (123 &#8220;okay&#8221; errors and one &#8220;proper&#8221; error), are you going to notice?</p>
<p>How about if you went from completely valid and zero errors to invalid and one error?  Will you notice then?</p>
<p>What about when your new junior hire starts making mistakes?  Is he qualified to know when some errors are okay and others aren&#8217;t?  Are you going to spot his mistakes even if he doesn&#8217;t?</p>
<p>When there&#8217;s no way to do what you want and also conform to the specification, I understand deviating from spec.  But there&#8217;s really no need for inventing new attributes.  Sure, you might be able to cut a few corners here and there, but you are only shifting that extra work into QA.  Obviously the people who don&#8217;t do any QA won&#8217;t notice and tout the &#8220;savings&#8221;, but it&#8217;s really just false economy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalle Wibeck</title>
		<link>http://www.robertnyman.com/2005/10/11/how-bad-is-an-invalid-attribute/#comment-1259</link>
		<dc:creator>Kalle Wibeck</dc:creator>
		<pubDate>Tue, 11 Oct 2005 11:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/?p=203#comment-1259</guid>
		<description>Of course there are times when you have no option but to compromise in order to "get a project to harbor" (anglification of a swedish saying).

I think that there are two ways of seeing this, the HTML and the XML way.
In the world of HTML there has always been quirks and I believe that that it will continue to be like that as long as non-pro's are maintaining their personal websites...
But in the world of XML a "faulty" attribute would force you to remove the attribute or update your DTD.

If you as a developer have comitted yourself to deliver standards compliant code in a business agreement you actually don't have the option to ignore some faulty attributes, if you stick to the agreement that is...

// :) Kalle

BTW: has anyone tried running the W3C validator on a page with a custom DTD? Does it work at all?</description>
		<content:encoded><![CDATA[<p>Of course there are times when you have no option but to compromise in order to &#8220;get a project to harbor&#8221; (anglification of a swedish saying).</p>
<p>I think that there are two ways of seeing this, the <acronym title="HyperText Markup Language">HTML</acronym> and the <acronym title="eXtensible Markup Language">XML</acronym> way.<br />
In the world of <acronym title="HyperText Markup Language">HTML</acronym> there has always been quirks and I believe that that it will continue to be like that as long as non-pro&#8217;s are maintaining their personal websites&#8230;<br />
But in the world of <acronym title="eXtensible Markup Language">XML</acronym> a &#8220;faulty&#8221; attribute would force you to remove the attribute or update your <acronym title="Document Type Definition">DTD</acronym>.</p>
<p>If you as a developer have comitted yourself to deliver standards compliant code in a business agreement you actually don&#8217;t have the option to ignore some faulty attributes, if you stick to the agreement that is&#8230;</p>
<p>// <img src='http://www.robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Kalle</p>
<p>BTW: has anyone tried running the <acronym title="World Wide Web Consortium">W3C</acronym> validator on a page with a custom <acronym title="Document Type Definition">DTD</acronym>? Does it work at all?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
