Another "morality" question: ID or class?

Discussion in 'HTML' started by spaghetti, Sep 23, 2003.

  1. spaghetti

    spaghetti Guest

    I know the technical differences between ID and class, but when (in a
    zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
    or class?

    I'm assuming class should be used almost all the time, especially when
    working with style sheets, and that ID should only be used to reference
    particular sections of a document from other documents?
     
    spaghetti, Sep 23, 2003
    #1
    1. Advertising

  2. spaghetti

    Adrienne Guest

    Gazing into my crystal ball I observed "spaghetti" <>
    writing in news:VL_bb.2102$:

    > I know the technical differences between ID and class, but when (in a
    > zen/standards/schematic/just-to-be-good sense) is it appropriate to use
    > ID or class?
    >
    > I'm assuming class should be used almost all the time, especially when
    > working with style sheets, and that ID should only be used to reference
    > particular sections of a document from other documents?
    >
    >


    <div id="header">
    <ul><li>menu item 1</li></ul>
    </div>
    <div id="content">
    <h1 class="titles" id="header1">Title</h1>
    <p>Something</p>
    </div>
    <div id="footer">
    Copywrite ...<a href="#header1">Head</a>
    </div>


    Very nice for making templates, especially templates using include files.
    --
    Adrienne Boswell
    Please respond to the group so others can share
    http://www.arbpen.com
     
    Adrienne, Sep 23, 2003
    #2
    1. Advertising

  3. spaghetti

    Kae Verens Guest

    spaghetti wrote:
    > I know the technical differences between ID and class, but when (in a
    > zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
    > or class?
    >
    > I'm assuming class should be used almost all the time, especially when
    > working with style sheets, and that ID should only be used to reference
    > particular sections of a document from other documents?


    id is for unique items - ie: there should only be one specific id per page
    class is for common items - ie: items which share common features could
    be of the same class

    for example, I have the id "Kae Verens", and am of the class "web
    developer" - the id is unique, but the class is common.

    Kae
     
    Kae Verens, Sep 23, 2003
    #3
  4. spaghetti

    PTG Guest

    "spaghetti" <> wrote in message
    news:VL_bb.2102$...
    > I know the technical differences between ID and class, but when (in a
    > zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
    > or class?
    >
    > I'm assuming class should be used almost all the time, especially when
    > working with style sheets, and that ID should only be used to reference
    > particular sections of a document from other documents?


    You use ID when there's just one instance of an element you want styling.
    You use class when there are multiple elements you want to style with one
    selector.

    Classes should actually be used rarely, because you should be able to use
    nested selectors in CSS in most cases (such as '#content p strong {
    stuff }')

    ID attributes are a good thing to use in HTML because they identify an
    element and can also be used for page anchors.
     
    PTG, Sep 23, 2003
    #4
    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. cyril
    Replies:
    2
    Views:
    3,946
    cyril
    Aug 25, 2004
  2. E11
    Replies:
    1
    Views:
    4,940
    Thomas Weidenfeller
    Oct 12, 2005
  3. cppaddict

    typedef Morality

    cppaddict, Jun 3, 2004, in forum: C++
    Replies:
    11
    Views:
    572
  4. cppaddict

    Morality of std:: prefix

    cppaddict, Jun 6, 2004, in forum: C++
    Replies:
    7
    Views:
    478
    Jeff Schwab
    Jun 7, 2004
  5. marekw2143
    Replies:
    3
    Views:
    1,398
    marekw2143
    Jul 25, 2009
Loading...

Share This Page