W3C home > Mailing lists > Public > www-validator@w3.org > September 2008

Re: img tag onload not validated

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Mon, 29 Sep 2008 18:01:52 +0300
Message-ID: <BD36F05F0DC641149CAB813EB6F7A402@JukanPC>
To: <www-validator@w3.org>
Cc: "pconver" <pconver@gmail.com>

Henri Sivonen wrote:
> On Sep 28, 2008, at 23:40, Benjamin Hawkes-Lewis wrote:
[...]
>> In HTML 4.01 Transitional, only the BODY element may have an ONLOAD
>> attribute:
[...]
> onload on <img> is allowed in HTML5, so this can be resolved by
> upgrading the validation target.

"HTML5" is just a name for an incomplete sketch of a draft, so I don't see 
the point.

If you just want to pass validation, you can simply create a local copy of 
an HTML 4.01 DTD and edit it so that onload is allowed for <img>. You don't 
have to "buy" blindly whatever might be in an HTML5 DTD this week.

Of course, this would not affect the _functionality_ of the page. If there 
is reliable documentation on actual browser behavior that says that onload 
for <img> is well-supported, you could keep using it, though browser 
behavior may well change when it comes to "nonstandard" attributes.

To stay on the safe side, just use onload in the <body> element where it is 
"standard", and write your script so that it refers to the image as needed 
(e.g., using an id attribute for it). This way, your onload operations will 
take place in a well-defined order. (If several onload attributes are used 
and supported, what would be their execution order?)

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/ 
Received on Monday, 29 September 2008 15:03:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:32 GMT