Click to See Complete Forum and Search --> : More quotes than I need...


tracknut
08-25-2009, 11:30 AM
I think it's legal to skip quotes in a lot of places where it's common to use them. For example,


<div id="article">


seems to be the norm, but could also be written:


<div id=article>


Correct, yes? In many cases, the extra quotes here and there aren't worth arguing about, but in a case where you have html being generated by a script, say php cranking through a database displaying a table, you may have a ton of quotes used in this manner that could be skipped.

Is there any downside to not including these quotes?

Thanks
Dave

Charles
08-25-2009, 12:02 PM
Is there any downside to not including these quotes?Only that it requires you to remember the rule governing when they can be omitted.In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.
http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2

tracknut
08-25-2009, 12:46 PM
Thanks Charles. I think I got it. The previous sentence to the one you quoted is:

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. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference &quot;.


So as long as the attribute does not contain quotes itself, or anything outside of the list you quoted above, I could skip quoting the attribute value.

Thanks,
Dave