[Javascript] OT: W3C

liorean liorean at f2o.org
Wed May 26 10:15:30 CDT 2004


Hassan Schroeder wrote:
> Shawn Milo wrote:
> 
>> The reason for using double quotes around HTML attributes is that the
>> W3C (http://www.w3.org/), the standards body which defines HTML, CSS, 
>> XHTML, etc., has made that the standard.
> 
> 
> citing <http://www.w3.org/TR/html4/intro/sgmltut.html#attributes>
> 
>     By default, SGML requires that all attribute values be
>     delimited using either double quotation marks (ASCII decimal
>     34) or single quotation marks (ASCII decimal 39). Single
>     quote marks can be included within the attribute value when
>     the value is delimited by double quote marks, and vice versa.
> 
> ...unless you have another reference to the contrary... :-)

There's a number of practical reasons for using double quotes, though:
 - Consistency with everyone else.
 - Double quotes allows you to use single quotes/apostrophes inside, which means that you can write regular English in it without escaping them.
 - For most uses, people tend to use single quotes in JavaScript. This makes for good JavaScript/HTML compatibility. JavaScript can be contained in an attribute value, and HTML can be contained within a JavaScript string, without requiring escaping.
 - Same goes for inline CSS and properties such as font-family, that may need quoting it's values.
-- 
David "liorean" Andersson

ViewStyles, ViewScripts, SwitchStyles and GraphicsInfo bookmarklets:
<http://liorean.web-graphics.com/>
Hangouts:
<http://codingforums.com/> <http://yourmusicforums.com/>



More information about the Javascript mailing list