perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Aubrey <maur...@hevanet.com>
Subject Re: [OT] using single quotes in HTML
Date Mon, 25 Feb 2002 01:11:34 GMT
On Sat, Feb 23, 2002 at 11:44:30PM -0500, Philip Mak wrote:
> I've seen the following programming style used before, for perl code
> that prints HTML:
> 
> 	print "<font color='red'>ERROR!</font>";
> 
> instead of:
> 
> 	print "<font color=\"red\">ERROR!</font>";
> 
> Using the single quotes for the quotes in HTML allows for cleaner
> syntax in perl, since then \" or qq{} is not required.
> 
> Does anyone know if there is a disadvantage of using single quotes in
> HTML (e.g. compatibility issues somewhere? I'm not sure because almost
> everyone only uses double quotes in HTML).

>From the HTML 4.01 spec:

  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 (&#34;) and single quotes (&#39;). For
  double quotes authors can also use the character entity reference &quot;.

  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>

XHTML requires that attributes are always quoted, so it's good idea to
follow that final recommendation if you intend to transition to it.
  
  <http://www.w3.org/TR/xhtml1/#diffs>

Also, weblint has always warned about the use of single quotes:

  try.html(4): use of ' for attribute value delimiter is not supported by
  all browsers (attribute BORDER of tag TABLE)

Weblint is pretty obsolete (looks like the last update was in 97),
so that may be referencing some very old browsers.

Maurice

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message