[whatwg] Make quoted attributes a conformance criteria

Simon Pieters simonp at opera.com
Mon Jul 27 02:10:05 PDT 2009


On Sat, 25 Jul 2009 12:08:23 +0200, Eduard Pascual <herenvardo at gmail.com>  
wrote:

> On Fri, Jul 24, 2009 at 9:52 PM, Keryx Web<webmaster at keryx.se> wrote:
>> On 2009-07-23 20:32, Eduard Pascual wrote:
>>>
>>> While I don't consider a hard requirement would be appropriate, there
>>> is an audience sector this discussion seems to be ignoring: Authoring
>>> Tools' developers. IMO, it would be highly desirable to have some
>>> guidelines for these tools to determine when they*should*  quote
>>> attribute values.
>>
>>
>> There is one further rub. Code that initially has been made by authoring
>> tools have a tendency to wind up in some front end developers lap, to be
>> amended and/or fixed manually at a later stage. That is even more a  
>> reason
>> for a strong recommendation about quotes.
>>
>> Furthermore, I doubt that most people on this list did read my blog  
>> post I
>> included as an URL when starting this discussion.[1]
> I can't speak for others, but I did read your post. And still I am
> convinced that a hard requirement to quote all values is not the best
> solution. There are some values that MUST be quoted, some that SHOULD
> be quoted, and even some that SHOULD NOT be quoted. Those that must be
> quoted are already covered by the spec, and validators will yield the
> relevant error message when encountering such values unquoted. For
> those values that *should* be quoted (those that improve in
> readability when quoted, or those that could lead to errors when they
> are later changed if unquoted), a warning from the validator should be
> enough. Finally, there are some values that are better unquoted, such
> as those attributes that can only take a number (there is no risk of
> errors, and the quotes would normally hurt readability more than they
> help it).

Actually boolean attributes are allowed to take the empty string as value,  
and it's not allowed to leave the empty string unquoted. However, boolean  
attributes aren't subject to the template/backend mismatch because you  
have to omit the attribute altogether for the false value, so the backend  
developer has to be responsible for writing out the whole attribute.  
Therefore, it should be safe to leave boolean attributes unquoted.

It should be safe to leave any attribute in the minimized form, because it  
also isn't subject to the template/backend mismatch.

Non-boolean attributes that are safe to leave unquoted:
<link hreflang>
<meta http-equiv>
<meta charset>
<script charset>
<article pubdate>
<ol start>
<li value>
<a hreflang>
<time datetime>
<progress value max>
<meter value min low high max optimum>
<bdo dir>
<ins datetime>
<del datetime>
<img width height>
<iframe width height>
<embed width height>
<object width height>
<video width height>
<canvas width height>
<area shape hreflang>
<colgroup span>
<col span>
<td colspan rowspan>
<th colspan rowspan scope>
<form autocomplete enctype method>
<input autocomplete formenctype formmethod height max maxlength min size  
step type width>
<button formenctype formmethod>
<select size>
<textarea cols maxlength rows wrap>
<keygen keytype>
<command type>
<bb type>

Global non-boolean attributes that are safe to leave unquoted:
dir
tabindex

All other attributes can take one of the special characters [\s"'<>] in  
the value, or the empty string as the value.

-- 
Simon Pieters
Opera Software


More information about the whatwg mailing list