Whitespace in attribute values

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Ca%20href%3D%22%20%20%20http%3A%2F%2Fgoogle.com%2Fsearch%3Fq%3Dhello%20%20world%20%20%20%20%20%22%20class%3D%22%20%20%20raga%20taga%20%20%20%20%22%20new%3D%22%20%20%20raga%20%20haga%20%20%22%3Emeow%3C%2Fa%3E%0A

<!DOCTYPE html>
<a href="   http://google.com/search?q=hello  world     "
    class="   raga taga    " new="   raga  haga  ">meow</a>

I can't find anywhere in the spec which defines how to deal with 
whitespace in attribute values.  Special handling seems to be in 
browsers for the "href" and "class" attributes, and more general 
handling in others.

Opera and Safari3 trim any runs of whitespace in any attribute value 
into just one space character.  Ff3 does this but also then removes any 
leading or trailing spaces from the class attribute.

IE removes all leading or trailing whitespace from the href attribute's 
value, leaving other attribute values as written.


This isn't much of an interoperability issue except in the case of the 
href attribute.  When following the href attribute, all browsers remove 
at least any leading or trailing whitespace and URL-encode the rest, 
even if the DOM has some leading/trailing whitespace.  Behaviour in this 
case should be defined.

-- 
Andrew Sidwell

Received on Saturday, 24 May 2008 16:24:44 UTC