www.webdeveloper.com
Results 1 to 3 of 3

Thread: More quotes than I need...

  1. #1
    Join Date
    Aug 2006
    Posts
    1,909

    More quotes than I need...

    I think it's legal to skip quotes in a lot of places where it's common to use them. For example,

    Code:
    <div id="article">
    seems to be the norm, but could also be written:

    Code:
    <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

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by tracknut View Post
    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
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Aug 2006
    Posts
    1,909
    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 (&#34 and single quotes (&#39. 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles