quotes in class/id names

Discussion in 'HTML' started by richard, Dec 18, 2007.

  1. richard

    richard Guest

    are the quotes in like class="name" absolutely necessary?
     
    richard, Dec 18, 2007
    #1
    1. Advertising

  2. richard wrote:
    > are the quotes in like class="name" absolutely necessary?


    In XHTML, yes. In HTML, not if the name consists of only letters,
    digits, underscores, hyphens, periods, and colons.

    But it's still good practice to use them. It makes your code more
    readable, because inconsistency makes code more difficult to read. You
    *will* need quotes, for example, for URLs that contain slashes, text
    field values that include spaces, and so forth. It also makes the code
    easier to write: you don't have to keep thinking, for each attribute,
    "Wait, can I get by without quotes on this one?" It's more flexible
    because, for example, you can use multiple classes as in
    class="thisclass thatclass" without making them a special case.

    Besides, why would you want to omit them?
     
    Harlan Messinger, Dec 18, 2007
    #2
    1. Advertising

  3. richard

    richard Guest

    On Tue, 18 Dec 2007 11:04:35 -0500, Harlan Messinger
    <> wrote:

    >richard wrote:
    >> are the quotes in like class="name" absolutely necessary?

    >
    >In XHTML, yes. In HTML, not if the name consists of only letters,
    >digits, underscores, hyphens, periods, and colons.
    >
    >But it's still good practice to use them. It makes your code more
    >readable, because inconsistency makes code more difficult to read. You
    >*will* need quotes, for example, for URLs that contain slashes, text
    >field values that include spaces, and so forth. It also makes the code
    >easier to write: you don't have to keep thinking, for each attribute,
    >"Wait, can I get by without quotes on this one?" It's more flexible
    >because, for example, you can use multiple classes as in
    >class="thisclass thatclass" without making them a special case.
    >
    >Besides, why would you want to omit them?


    Just curious. I've run a page I'm working on through the validator and
    it doesn't seem to care about that.
     
    richard, Dec 18, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,880
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,698
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,519
    Andrew Thompson
    Dec 24, 2003
  4. jOhn
    Replies:
    1
    Views:
    237
    Phlip
    Jan 29, 2008
  5. Richard Sandoval
    Replies:
    5
    Views:
    211
    7stud --
    Apr 26, 2011
Loading...

Share This Page